Skip to content

Commit 7b8116c

Browse files
authored
Merge pull request #2 from bringauto/BAF-805/cmdef-package
Baf 805/cmdef package
2 parents 62854ac + 64cc2d1 commit 7b8116c

File tree

15 files changed

+52
-105
lines changed

15 files changed

+52
-105
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "lib/fleet-protocol"]
2-
path = lib/fleet-protocol
3-
url = https://github.com/bringauto/fleet-protocol.git

CMakeLists.txt

Lines changed: 26 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SET(CMAKE_CXX_STANDARD 20)
77
SET(CMAKE_CXX_EXTENSIONS OFF) # For increased portability
88
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
99

10-
SET(INTERNAL_CLIENT_VERSION 1.0.0)
10+
SET(INTERNAL_CLIENT_VERSION 1.1.0)
1111

1212
OPTION(BRINGAUTO_SAMPLES OFF)
1313
OPTION(BRINGAUTO_TESTS "Enable tests" OFF)
@@ -32,94 +32,42 @@ IF (BRINGAUTO_PACKAGE AND NOT BRINGAUTO_INSTALL)
3232
)
3333
ENDIF ()
3434

35-
ADD_SUBDIRECTORY(${CMAKE_CURRENT_LIST_DIR}/lib/fleet-protocol)
36-
37-
ADD_LIBRARY(internal_client_api INTERFACE)
38-
TARGET_INCLUDE_DIRECTORIES(internal_client_api INTERFACE
39-
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/lib/fleet-protocol/lib/internal_client/include> $<INSTALL_INTERFACE:include>
40-
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/lib/fleet-protocol/lib/common_headers/include> $<INSTALL_INTERFACE:include>
41-
)
35+
FIND_PACKAGE(fleet-protocol-interface 2.0.0 REQUIRED)
36+
FIND_PACKAGE(protobuf 3.21.12 REQUIRED)
4237

4338
FILE(GLOB_RECURSE source_files "${CMAKE_CURRENT_LIST_DIR}/source/*")
39+
CMDEF_ADD_LIBRARY(
40+
LIBRARY_GROUP internal-client
41+
TYPE SHARED
42+
SOURCES ${source_files}
43+
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include/"
44+
VERSION ${INTERNAL_CLIENT_VERSION}
45+
)
4446

45-
ADD_LIBRARY(internal_client SHARED ${source_files})
46-
TARGET_INCLUDE_DIRECTORIES(internal_client PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
47-
TARGET_LINK_LIBRARIES(internal_client PUBLIC internal_client_api)
48-
TARGET_LINK_LIBRARIES(internal_client PRIVATE protobuf_cpp)
47+
TARGET_LINK_LIBRARIES(internal-client-shared
48+
PUBLIC
49+
fleet-protocol-interface::common-headers-interface
50+
fleet-protocol-interface::internal-client-interface
51+
PRIVATE
52+
protobuf::libprotobuf
53+
fleet-protocol-interface::protobuf-cpp-interface
54+
)
4955

5056

5157
IF (BRINGAUTO_INSTALL)
52-
INCLUDE(GNUInstallDirs)
53-
54-
INSTALL(TARGETS internal_client EXPORT internal_clientTargets
55-
LIBRARY DESTINATION lib
56-
ARCHIVE DESTINATION lib
57-
RUNTIME DESTINATION bin
58-
INCLUDES DESTINATION include
59-
)
60-
61-
INSTALL(TARGETS internal_client_api EXPORT internal_clientTargets
62-
LIBRARY DESTINATION lib
63-
ARCHIVE DESTINATION lib
64-
RUNTIME DESTINATION bin
65-
INCLUDES DESTINATION include
66-
)
67-
68-
INSTALL(
69-
DIRECTORY
70-
${CMAKE_CURRENT_SOURCE_DIR}/lib/fleet-protocol/lib/common_headers/include/
71-
DESTINATION include
72-
COMPONENT Devel
73-
)
74-
75-
INSTALL(
76-
DIRECTORY
77-
${CMAKE_CURRENT_SOURCE_DIR}/lib/fleet-protocol/lib/internal_client/include/
78-
DESTINATION include
79-
COMPONENT Devel
80-
)
81-
82-
INCLUDE(CMakePackageConfigHelpers)
83-
CONFIGURE_PACKAGE_CONFIG_FILE(
84-
cmake/internal_clientConfig.cmake
85-
${CMAKE_CURRENT_BINARY_DIR}/internal_client/internal_clientConfig.cmake
86-
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/internal_client/cmake
87-
)
88-
89-
WRITE_BASIC_PACKAGE_VERSION_FILE(
90-
"${CMAKE_CURRENT_BINARY_DIR}/internal_client/internal_clientConfigVersion.cmake"
91-
VERSION ${INTERNAL_CLIENT_VERSION}
92-
COMPATIBILITY SameMajorVersion
93-
)
94-
95-
EXPORT(EXPORT internal_clientTargets
96-
FILE "${CMAKE_CURRENT_BINARY_DIR}/internal_client/internal_clientTargets.cmake"
97-
)
98-
99-
SET(ConfigPackageLocation lib/cmake/internal_client)
100-
INSTALL(EXPORT internal_clientTargets
101-
FILE
102-
internal_clientTargets.cmake
103-
DESTINATION
104-
${ConfigPackageLocation}
105-
)
106-
107-
INSTALL(
108-
FILES
109-
cmake/internal_clientConfig.cmake
110-
${CMAKE_CURRENT_BINARY_DIR}/internal_client/internal_clientConfigVersion.cmake
111-
DESTINATION
112-
${ConfigPackageLocation}
113-
COMPONENT
114-
Devel
58+
CMDEF_INSTALL(
59+
TARGET internal-client-shared
60+
NAMESPACE internal-client-shared::
11561
)
11662
ENDIF ()
11763

11864
IF (BRINGAUTO_PACKAGE)
65+
CMDEF_PACKAGE(
66+
MAIN_TARGET internal-client-shared
67+
VERSION ${INTERNAL_CLIENT_VERSION}
68+
)
11969
SET(CPACK_GENERATOR ZIP)
120-
SET(CPACK_PACKAGE_CONTACT "Jakub Trubka <jakub.trubka@bringauto.com>")
121-
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jakub Trubka <jakub.trubka@bringauto.com>")
122-
SET(CPACK_PACKAGE_VERSION ${libbringauto_logger_VERSION})
70+
SET(CPACK_PACKAGE_CONTACT "BringAuto s.r.o. <maintainers@bringauto.com>")
12371
INCLUDE(CPack)
12472
ENDIF ()
12573

cmake/Dependencies.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SET(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE)
2+
3+
BA_PACKAGE_LIBRARY(fleet-protocol-interface v2.0.0 PLATFORM_STRING_MODE any_machine NO_DEBUG ON)
4+
BA_PACKAGE_LIBRARY(protobuf v4.21.12)
5+
BA_PACKAGE_LIBRARY(zlib v1.2.11)

examples/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.25 FATAL_ERROR)
33
ADD_EXECUTABLE(example main.cpp)
44

55
IF (INTERNAL_CLIENT_INSTALLED)
6-
FIND_PACKAGE(internal-client REQUIRED)
6+
FIND_PACKAGE(internal-client-shared REQUIRED)
77
ENDIF ()
88

9-
TARGET_LINK_LIBRARIES(example PUBLIC internal_client)
10-
11-
TARGET_LINK_LIBRARIES(example PRIVATE protobuf_cpp) # Linking protobuf files only for example usage
9+
TARGET_LINK_LIBRARIES(example PUBLIC internal-client-shared)

examples/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include <internal_client.h>
2-
#include <memory_management.h>
1+
#include <fleet_protocol/internal_client/internal_client.h>
2+
#include <fleet_protocol/common_headers/memory_management.h>
33
#include <iostream>
4-
#include <modules/CarAccessoryModule.pb.h>
4+
#include <cstring>
55

66

77
int main() {

include/Communication.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <Context.hpp>
44
#include <protobuf/ProtoSerializer.hpp>
55

6-
#include <memory_management.h>
6+
#include <fleet_protocol/common_headers/memory_management.h>
77

88
class Communication {
99
public:

include/Context.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include <device_management.h>
4-
#include <memory_management.h>
3+
#include <fleet_protocol/common_headers/device_management.h>
4+
#include <fleet_protocol/common_headers/memory_management.h>
55
#include <InternalProtocol.pb.h>
66

77
#include <condition_variable>

include/protobuf/ProtoSerializer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <memory_management.h>
3+
#include <fleet_protocol/common_headers/memory_management.h>
44
#include <InternalProtocol.pb.h>
55

66
namespace protobuf {

lib/fleet-protocol

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/Communication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <Communication.hpp>
22
#include <helpers/EnumMappers.hpp>
33

4-
#include <ic_error_codes.h>
4+
#include <fleet_protocol/internal_client/error_codes.h>
55

66

77
int Communication::sendConnectMessage(Context *context) {

0 commit comments

Comments
 (0)