forked from CppMicroServices/CppMicroServices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
458 lines (387 loc) · 18.9 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed" CACHE PATH "default install path" FORCE )
endif()
project(CppMicroServices)
set(${PROJECT_NAME}_MAJOR_VERSION 2)
set(${PROJECT_NAME}_MINOR_VERSION 1)
set(${PROJECT_NAME}_PATCH_VERSION 1)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION})
cmake_minimum_required(VERSION 2.8)
cmake_policy(VERSION 2.8)
cmake_policy(SET CMP0017 NEW)
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH}
)
#-----------------------------------------------------------------------------
# CMake function(s) and macro(s)
#-----------------------------------------------------------------------------
include(CMakeParseArguments)
include(CMakePackageConfigHelpers)
include(CheckCXXSourceCompiles)
include(usFunctionCheckCompilerFlags)
include(usFunctionEmbedResources)
include(usFunctionGetGccVersion)
include(usFunctionGenerateModuleInit)
include(usFunctionGenerateExecutableInit)
#-----------------------------------------------------------------------------
# Init output directories
#-----------------------------------------------------------------------------
set(US_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(US_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(US_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
foreach(_type ARCHIVE LIBRARY RUNTIME)
if(NOT CMAKE_${_type}_OUTPUT_DIRECTORY)
set(CMAKE_${_type}_OUTPUT_DIRECTORY ${US_${_type}_OUTPUT_DIRECTORY})
endif()
endforeach()
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
#-----------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug+Release' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#-----------------------------------------------------------------------------
# CMake options
#-----------------------------------------------------------------------------
function(us_cache_var _var_name _var_default _var_type _var_help)
set(_advanced 0)
set(_force)
foreach(_argn ${ARGN})
if(_argn STREQUAL ADVANCED)
set(_advanced 1)
elseif(_argn STREQUAL FORCE)
set(_force FORCE)
endif()
endforeach()
if(US_IS_EMBEDDED)
if(NOT DEFINED ${_var_name} OR _force)
set(${_var_name} ${_var_default} PARENT_SCOPE)
endif()
else()
set(${_var_name} ${_var_default} CACHE ${_var_type} "${_var_help}" ${_force})
if(_advanced)
mark_as_advanced(${_var_name})
endif()
endif()
endfunction()
# Determine if we are being build inside a larger project
if(NOT DEFINED US_IS_EMBEDDED)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(US_IS_EMBEDDED 0)
else()
set(US_IS_EMBEDDED 1)
set(CppMicroServices_EXPORTS 1)
endif()
endif()
# Determine the name of the install component for "SDK" artifacts.
# The default is "sdk"
if(NOT DEFINED US_SDK_INSTALL_COMPONENT)
set(US_SDK_INSTALL_COMPONENT COMPONENT sdk)
elseif(US_SDK_INSTALL_COMPONENT)
set(US_SDK_INSTALL_COMPONENT COMPONENT ${US_SDK_INSTALL_COMPONENT})
endif()
us_cache_var(US_ENABLE_AUTOLOADING_SUPPORT OFF BOOL "Enable module auto-loading support")
us_cache_var(US_ENABLE_THREADING_SUPPORT OFF BOOL "Enable threading support")
us_cache_var(US_ENABLE_DEBUG_OUTPUT OFF BOOL "Enable debug messages" ADVANCED)
us_cache_var(US_ENABLE_RESOURCE_COMPRESSION ON BOOL "Enable resource compression" ADVANCED)
us_cache_var(US_BUILD_SHARED_LIBS ON BOOL "Build shared libraries")
us_cache_var(US_BUILD_TESTING OFF BOOL "Build tests")
us_cache_var(US_NAMESPACE "us" STRING "The namespace for the C++ micro services entities")
us_cache_var(US_HEADER_PREFIX "" STRING "The file name prefix for the public C++ micro services header files")
set(default_runtime_install_dir bin/)
set(default_library_install_dir lib/)
set(default_archive_install_dir lib/${PROJECT_NAME})
set(default_header_install_dir include/${US_NAMESPACE})
set(default_auxiliary_install_dir lib/cmake/${PROJECT_NAME})
us_cache_var(RUNTIME_INSTALL_DIR ${default_runtime_install_dir} STRING "Relative install location for binaries" ADVANCED)
us_cache_var(LIBRARY_INSTALL_DIR ${default_library_install_dir} STRING "Relative install location for libraries" ADVANCED)
us_cache_var(ARCHIVE_INSTALL_DIR ${default_archive_install_dir} STRING "Relative install location for archives" ADVANCED)
us_cache_var(HEADER_INSTALL_DIR ${default_header_install_dir} STRING "Relative install location for headers" ADVANCED)
us_cache_var(AUXILIARY_INSTALL_DIR ${default_auxiliary_install_dir} STRING "Relative install location for cmake files" ADVANCED)
set(BUILD_SHARED_LIBS ${US_BUILD_SHARED_LIBS})
set(${PROJECT_NAME}_MODULE_INIT_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/usModuleInit.cpp" CACHE INTERNAL "The module initialization template code")
set(${PROJECT_NAME}_EXECUTABLE_INIT_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/usExecutableInit.cpp" CACHE INTERNAL "The executable initialization template code")
#-----------------------------------------------------------------------------
# US C/CXX Flags
#-----------------------------------------------------------------------------
set(US_C_FLAGS)
set(US_C_FLAGS_RELEASE)
set(US_CXX_FLAGS)
set(US_CXX_FLAGS_RELEASE)
# Set C++ compiler flags
if(NOT MSVC)
foreach(_cxxflag -Werror -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align
-Wwrite-strings -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast
-Wstrict-null-sentinel -Wsign-promo -fdiagnostics-show-option)
usFunctionCheckCompilerFlags(${_cxxflag} US_CXX_FLAGS)
endforeach()
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
usFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
if(${GCC_VERSION} VERSION_LESS "4.0.0")
message(FATAL_ERROR "gcc version ${GCC_VERSION} not supported. Please use gcc >= 4.")
endif()
# With older versions of gcc the flag -fstack-protector-all requires an extra dependency to libssp.so.
# If the gcc version is lower than 4.4.0 and the build type is Release let's not include the flag.
if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0"))
usFunctionCheckCompilerFlags("-fstack-protector-all" US_CXX_FLAGS)
endif()
if(MINGW)
# suppress warnings about auto imported symbols
set(US_CXX_FLAGS "-Wl,--enable-auto-import ${US_CXX_FLAGS}")
# we need to define a Windows version
set(US_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${US_CXX_FLAGS}")
else()
# Enable visibility support
if(NOT ${GCC_VERSION} VERSION_LESS "4.5")
usFunctionCheckCompilerFlags("-fvisibility=hidden -fvisibility-inlines-hidden" US_CXX_FLAGS)
else()
set(US_GCC_RTTI_WORKAROUND_NEEDED 1)
endif()
endif()
usFunctionCheckCompilerFlags("-O1 -D_FORTIFY_SOURCE=2" _fortify_source_flag)
if(_fortify_source_flag)
set(US_CXX_FLAGS_RELEASE "${US_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
endif()
elseif(MSVC)
set(US_CXX_FLAGS "/MP /WX /wd4996 /wd4251 /wd4503 ${US_CXX_FLAGS}")
endif()
if(NOT US_IS_EMBEDDED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${US_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${US_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${US_C_FLAGS}")
set(CMAKE_C_FLAGS_REALEASE "${CMAKE_C_FLAGS_RELEASE} ${US_C_FLAGS_RELEASE}")
endif()
#-----------------------------------------------------------------------------
# US Link Flags
#-----------------------------------------------------------------------------
set(US_LINK_FLAGS )
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
foreach(_linkflag -Wl,--no-undefined)
set(_add_flag)
usFunctionCheckCompilerFlags("${_linkflag}" _add_flag)
if(_add_flag)
set(US_LINK_FLAGS "${US_LINK_FLAGS} ${_linkflag}")
endif()
endforeach()
endif()
#-----------------------------------------------------------------------------
# US Header Checks
#-----------------------------------------------------------------------------
include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
CHECK_INCLUDE_FILE_CXX(stdint.h US_HAVE_STDINT_H)
CHECK_INCLUDE_FILE_CXX(tr1/unordered_map US_HAVE_TR1_UNORDERED_MAP_H)
CHECK_INCLUDE_FILE_CXX(tr1/unordered_set US_HAVE_TR1_UNORDERED_SET_H)
CHECK_INCLUDE_FILE_CXX(tr1/functional US_HAVE_TR1_FUNCTIONAL_H)
CHECK_INCLUDE_FILE_CXX(unordered_map US_HAVE_UNORDERED_MAP_H)
CHECK_INCLUDE_FILE_CXX(unordered_set US_HAVE_UNORDERED_SET_H)
CHECK_INCLUDE_FILE_CXX(functional US_HAVE_FUNCTIONAL_H)
if(US_HAVE_UNORDERED_MAP_H)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nint main() { std::tr1::unordered_map<int,int> m; return 0; }"
US_HAVE_TR1_UNORDERED_MAP)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nint main() { std::unordered_map<int,int> m; return 0; }"
US_HAVE_STD_UNORDERED_MAP)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nint main() { std::tr1::hash<int>(); return 0; }"
US_HAVE_TR1_HASH)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nint main() { std::hash<int>(); return 0; }"
US_HAVE_STD_HASH)
if(US_HAVE_STD_HASH)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nstruct A { friend struct std::hash<int>; }; int main() { return 0; }"
US_HAVE_STD_HASH_STRUCT)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nstruct A { friend class std::hash<int>; }; int main() { return 0; }"
US_HAVE_STD_HASH_CLASS)
elseif(US_HAVE_TR1_HASH)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nstruct A { friend struct std::tr1::hash<int>; }; int main() { return 0; }"
US_HAVE_TR1_HASH_STRUCT)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>\nstruct A { friend class std::tr1::hash<int>; }; int main() { return 0; }"
US_HAVE_TR1_HASH_CLASS)
endif()
elseif(US_HAVE_TR1_UNORDERED_MAP_H)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nint main() { std::tr1::unordered_map<int,int> m; return 0; }"
US_HAVE_TR1_UNORDERED_MAP)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nint main() { std::unordered_map<int,int> m; return 0; }"
US_HAVE_STD_UNORDERED_MAP)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nint main() { std::tr1::hash<int>(); return 0; }"
US_HAVE_TR1_HASH)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nint main() { std::hash<int>(); return 0; }"
US_HAVE_STD_HASH)
if(US_HAVE_STD_HASH)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nstruct A { friend struct std::hash<int>; }; int main() { return 0; }"
US_HAVE_STD_HASH_STRUCT)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nstruct A { friend class std::hash<int>; }; int main() { return 0; }"
US_HAVE_STD_HASH_CLASS)
elseif(US_HAVE_TR1_HASH)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nstruct A { friend struct std::tr1::hash<int>; }; int main() { return 0; }"
US_HAVE_TR1_HASH_STRUCT)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_map>\nstruct A { friend class std::tr1::hash<int>; }; int main() { return 0; }"
US_HAVE_TR1_HASH_CLASS)
endif()
else()
message(SEND_ERROR "The header file \"unordered_map\" is not available.")
endif()
if(NOT (US_HAVE_TR1_UNORDERED_MAP OR US_HAVE_STD_UNORDERED_MAP))
message(SEND_ERROR "The \"unordered_map\" type is not available.")
endif()
if(US_HAVE_UNORDERED_SET_H)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_set>\nint main() { std::tr1::unordered_set<int> s; return 0; }"
US_HAVE_TR1_UNORDERED_SET)
CHECK_CXX_SOURCE_COMPILES("#include <unordered_set>\nint main() { std::unordered_set<int> s; return 0; }"
US_HAVE_STD_UNORDERED_SET)
elseif(US_HAVE_TR1_UNORDERED_SET_H)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_set>\nint main() { std::tr1::unordered_set<int> s; return 0; }"
US_HAVE_TR1_UNORDERED_SET)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/unordered_set>\nint main() { std::unordered_set<int> s; return 0; }"
US_HAVE_STD_UNORDERED_SET)
else()
message(SEND_ERROR "The header file \"unordered_set\" is not available.")
endif()
if(NOT (US_HAVE_TR1_UNORDERED_SET OR US_HAVE_STD_UNORDERED_SET))
message(SEND_ERROR "The \"unordered_set\" type is not available.")
endif()
if(NOT (US_HAVE_FUNCTIONAL_H OR US_HAVE_TR1_FUNCTIONAL_H))
message(SEND_ERROR "The header file \"functional\" is not available.")
endif()
if(US_HAVE_FUNCTIONAL_H)
CHECK_CXX_SOURCE_COMPILES("#include <functional>\nint main() { std::tr1::function<int(void)> f(main); return 0; }"
US_HAVE_TR1_FUNCTION)
CHECK_CXX_SOURCE_COMPILES("#include <functional>\nint main() { std::function<int(void)> f(main); return 0; }"
US_HAVE_STD_FUNCTION)
endif()
if((NOT (US_HAVE_STD_FUNCTION OR US_HAVE_TR1_FUNCTION)) AND US_HAVE_TR1_FUNCTIONAL_H)
unset(US_HAVE_TR1_FUNCTION CACHE)
unset(US_HAVE_STD_FUNCTION CACHE)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/functional>\nint main() { std::tr1::function<int(void)> f(main); return 0; }"
US_HAVE_TR1_FUNCTION)
CHECK_CXX_SOURCE_COMPILES("#include <tr1/functional>\nint main() { std::function<int(void)> f(main); return 0; }"
US_HAVE_STD_FUNCTION)
endif()
if(NOT (US_HAVE_STD_FUNCTION OR US_HAVE_TR1_FUNCTION))
message(SEND_ERROR "The \"function\" type is not available.")
endif()
#-----------------------------------------------------------------------------
# US include dirs and libraries
#-----------------------------------------------------------------------------
set(US_INCLUDE_DIRS
${PROJECT_BINARY_DIR}/include
)
set(US_INTERNAL_INCLUDE_DIRS
${PROJECT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src/util
${CMAKE_CURRENT_SOURCE_DIR}/src/service
${CMAKE_CURRENT_SOURCE_DIR}/src/module
)
# link library for third party libs
if(US_IS_EMBEDDED)
set(US_LIBRARY_TARGET ${US_EMBEDDING_LIBRARY})
else()
set(US_LIBRARY_TARGET ${PROJECT_NAME})
endif()
# link libraries for the CppMicroServices lib
set(US_LINK_LIBRARIES )
if(UNIX)
list(APPEND US_LINK_LIBRARIES dl)
endif()
#-----------------------------------------------------------------------------
# Source directory
#-----------------------------------------------------------------------------
set(us_config_h_file "${PROJECT_BINARY_DIR}/include/usConfig.h")
configure_file(usConfig.h.in ${us_config_h_file})
set(US_RCC_EXECUTABLE_NAME usResourceCompiler)
set(CppMicroServices_RCC_EXECUTABLE_NAME ${US_RCC_EXECUTABLE_NAME} CACHE INTERNAL "The target name of the usResourceCompiler executable.")
add_subdirectory(tools)
add_subdirectory(src)
#-----------------------------------------------------------------------------
# US testing
#-----------------------------------------------------------------------------
if(US_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------
add_subdirectory(documentation)
#-----------------------------------------------------------------------------
# Last configuration and install steps
#-----------------------------------------------------------------------------
if(NOT US_IS_EMBEDDED)
export(TARGETS ${PROJECT_NAME} ${US_RCC_EXECUTABLE_NAME}
FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${AUXILIARY_INSTALL_DIR}/)
endif()
set(_install_cmake_scripts
${${PROJECT_NAME}_MODULE_INIT_TEMPLATE}
${${PROJECT_NAME}_EXECUTABLE_INIT_TEMPLATE}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeParseArguments.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/usFunctionGenerateModuleInit.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/usFunctionGenerateExecutableInit.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/usFunctionEmbedResources.cmake
)
install(FILES ${_install_cmake_scripts}
DESTINATION ${AUXILIARY_INSTALL_DIR}/
)
# Configure CppMicroServicesConfig.cmake for the build tree
set(PACKAGE_CONFIG_INCLUDE_DIR ${US_INCLUDE_DIRS})
set(PACKAGE_CONFIG_RUNTIME_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(PACKAGE_CONFIG_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake)
if(US_IS_EMBEDDED)
set(PACKAGE_EMBEDDED "if(@PROJECT_NAME@_IS_EMBEDDED)
set(@PROJECT_NAME@_INTERNAL_INCLUDE_DIRS @US_INTERNAL_INCLUDE_DIRS@)
set(@PROJECT_NAME@_SOURCES @US_SOURCES@)
set(@PROJECT_NAME@_PUBLIC_HEADERS @US_PUBLIC_HEADERS@)
set(@PROJECT_NAME@_PRIVATE_HEADERS @US_PRIVATE_HEADERS@)
endif()")
else()
set(PACKAGE_EMBEDDED )
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
@ONLY
)
# Configure CppMicroServicesConfig.cmake for the install tree
set(CONFIG_INCLUDE_DIR ${HEADER_INSTALL_DIR})
set(CONFIG_RUNTIME_DIR ${RUNTIME_INSTALL_DIR})
set(CONFIG_CMAKE_DIR ${AUXILIARY_INSTALL_DIR})
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${AUXILIARY_INSTALL_DIR}/
PATH_VARS CONFIG_INCLUDE_DIR CONFIG_RUNTIME_DIR CONFIG_CMAKE_DIR
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Version information
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}ConfigVersion.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${AUXILIARY_INSTALL_DIR}/
${US_SDK_INSTALL_COMPONENT}
)
#-----------------------------------------------------------------------------
# Build the examples
#-----------------------------------------------------------------------------
option(US_BUILD_EXAMPLES "Build example projects" OFF)
if(US_BUILD_EXAMPLES)
if(NOT US_BUILD_SHARED_LIBS)
message(WARNING "Examples are not available if US_BUILD_SHARED_LIBS is OFF")
else()
set(CppMicroServices_DIR ${PROJECT_BINARY_DIR})
add_subdirectory(examples)
endif()
endif()