-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (137 loc) · 5.14 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
CMAKE_MINIMUM_REQUIRED(VERSION 3.25 FATAL_ERROR)
PROJECT(transparent_module CXX)
SET(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
SET(CMAKE_INSTALL_RPATH "$ORIGIN")
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_EXTENSIONS OFF) # For increased portability
INCLUDE(CheckPIESupported)
CHECK_PIE_SUPPORTED()
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(TRANSPARENT_MODULE_VERSION 1.0.0)
OPTION(BRINGAUTO_INSTALL "Configure install" OFF)
OPTION(BRINGAUTO_PACKAGE "Configure package creation" OFF)
OPTION(BRINGAUTO_SYSTEM_DEP "System dependencies are used if switched to ON, packager used if OFF" OFF)
OPTION(BRINGAUTO_GET_PACKAGES_ONLY "Only download packages for this project" OFF)
OPTION(FLEET_PROTOCOL_BUILD_MODULE_GATEWAY "Build shared library for module gateway " ON)
OPTION(FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER "Build shared library for external server " ON)
IF (BRINGAUTO_PACKAGE)
IF (NOT BRINGAUTO_INSTALL)
SET(BRINGAUTO_INSTALL ON
CACHE BOOL
"Installation forced by BRINGAUTO_PACKAGE creation"
FORCE
)
ENDIF ()
IF (NOT FLEET_PROTOCOL_BUILD_MODULE_GATEWAY)
SET(FLEET_PROTOCOL_BUILD_MODULE_GATEWAY ON
CACHE BOOL
"Module gateway module build forced by BRINGAUTO_PACKAGE creation"
FORCE
)
ENDIF ()
IF (NOT FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER)
SET(FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER ON
CACHE BOOL
"External server module build forced by BRINGAUTO_PACKAGE creation"
FORCE
)
ENDIF ()
ENDIF ()
FIND_PACKAGE(CMLIB
COMPONENTS CMDEF CMUTIL STORAGE
REQUIRED
)
IF (NOT BRINGAUTO_SYSTEM_DEP)
INCLUDE("cmake/Dependencies.cmake")
IF (BRINGAUTO_GET_PACKAGES_ONLY)
RETURN()
ENDIF ()
ENDIF ()
FIND_PACKAGE(nlohmann_json 3.10.5 REQUIRED)
FIND_PACKAGE(fleet-protocol-interface 2.0.0 REQUIRED)
FIND_PACKAGE(fleet-protocol-cxx-helpers-static 1.1.1 REQUIRED)
IF (FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER)
FIND_PACKAGE(fleet-http-client-shared 1.5.0 REQUIRED)
### fleet-http-client dependencies
FIND_PACKAGE(Boost REQUIRED)
FIND_PACKAGE(cpprestsdk REQUIRED)
ENDIF ()
CMDEF_ADD_LIBRARY(
LIBRARY_GROUP transparent-module
TYPE INTERFACE
VERSION ${TRANSPARENT_MODULE_VERSION}
)
FILE(GLOB_RECURSE HEADERS "include/*")
ADD_LIBRARY(transparent_module_hpp INTERFACE ${HEADERS})
TARGET_INCLUDE_DIRECTORIES(transparent_module_hpp INTERFACE "include/")
FILE(GLOB_RECURSE SOURCES "source/bringauto/*")
ADD_LIBRARY(transparent_module_sources STATIC ${SOURCES})
SET_PROPERTY(TARGET transparent_module_sources PROPERTY POSITION_INDEPENDENT_CODE ON)
TARGET_LINK_LIBRARIES(transparent_module_sources PUBLIC transparent_module_hpp
fleet-protocol-interface::common-headers-interface
fleet-protocol-cxx-helpers-static::fleet-protocol-cxx-helpers-static
nlohmann_json::nlohmann_json
)
IF (FLEET_PROTOCOL_BUILD_MODULE_GATEWAY)
CMDEF_ADD_LIBRARY(
LIBRARY_GROUP transparent-module-gateway
TYPE SHARED
SOURCES "source/module_manager.cpp" "source/memory_management.cpp" "source/device_management.cpp"
VERSION ${TRANSPARENT_MODULE_VERSION}
)
TARGET_LINK_LIBRARIES(transparent-module-gateway-shared
PRIVATE
transparent_module_sources
PUBLIC
fleet-protocol-interface::module-maintainer-module-gateway-interface
)
TARGET_LINK_LIBRARIES(transparent-module-interface INTERFACE
transparent-module-gateway-shared
)
ENDIF ()
IF (FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER)
CMDEF_ADD_LIBRARY(
LIBRARY_GROUP transparent-external-server
TYPE SHARED
SOURCES "source/external_server_api.cpp" "source/memory_management.cpp" "source/device_management.cpp"
VERSION ${TRANSPARENT_MODULE_VERSION}
)
TARGET_LINK_LIBRARIES(transparent-external-server-shared
PRIVATE
transparent_module_sources
fleet-http-client-shared::fleet-http-client-shared
PUBLIC
fleet-protocol-interface::module-maintainer-external-server-interface
)
TARGET_LINK_LIBRARIES(transparent-module-interface INTERFACE
transparent-external-server-shared
)
ENDIF ()
IF (BRINGAUTO_INSTALL)
IF (FLEET_PROTOCOL_BUILD_MODULE_GATEWAY)
CMDEF_INSTALL(
TARGET transparent-module-gateway-shared
NAMESPACE transparent-module-interface::
)
ENDIF ()
IF (FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER)
CMDEF_INSTALL(
TARGET transparent-external-server-shared
NAMESPACE transparent-module-interface::
)
ENDIF ()
CMDEF_INSTALL(
TARGET transparent-module-interface
NAMESPACE transparent-module-interface::
)
BA_PACKAGE_DEPS_IMPORTED(transparent-module-interface)
ENDIF ()
IF (BRINGAUTO_PACKAGE)
CMDEF_PACKAGE(
MAIN_TARGET transparent-module-interface
VERSION ${TRANSPARENT_MODULE_VERSION}
)
SET(CPACK_GENERATOR ZIP)
SET(CPACK_PACKAGE_CONTACT "BringAuto s.r.o. <[email protected]>")
INCLUDE(CPack)
ENDIF ()