1 # For internal use only
5 project(${_project_name})
7 cmake_parse_arguments(${PROJECT_NAME}
8 "SKIP_EXAMPLES;SKIP_INIT"
10 "DEPENDS;INTERNAL_INCLUDE_DIRS;LINK_LIBRARIES;SOURCES;PRIVATE_HEADERS;PUBLIC_HEADERS;RESOURCES;BINARY_RESOURCES"
14 if(NOT ${PROJECT_NAME}_VERSION MATCHES
"^[0-9]+\\.[0-9]+\\.[0-9]+$")
15 message(SEND_ERROR
"VERSION argument invalid: ${${PROJECT_NAME}_VERSION}")
18 string(REPLACE "." ";" _version_numbers ${${PROJECT_NAME}_VERSION})
19 list(GET _version_numbers 0 ${PROJECT_NAME}_MAJOR_VERSION)
20 list(GET _version_numbers 1 ${PROJECT_NAME}_MINOR_VERSION)
21 list(GET _version_numbers 2 ${PROJECT_NAME}_PATCH_VERSION)
23 if(NOT ${PROJECT_NAME}_TARGET)
24 set(${PROJECT_NAME}_TARGET
us${PROJECT_NAME})
26 set(PROJECT_TARGET ${${PROJECT_NAME}_TARGET})
28 if(${PROJECT_NAME}_DEPENDS)
29 find_package(CppMicroServices REQUIRED ${${PROJECT_NAME}_DEPENDS} QUIET
30 HINTS ${CppMicroServices_BINARY_DIR}
35 #-----------------------------------------------------------------------------
36 # Include dirs and libraries
37 #-----------------------------------------------------------------------------
39 set(${PROJECT_NAME}_INCLUDE_DIRS
40 ${CMAKE_CURRENT_SOURCE_DIR}/include
41 ${CMAKE_CURRENT_BINARY_DIR}/include
44 configure_file(${CppMicroServices_SOURCE_DIR}/cmake/usExport.h.in
45 ${CMAKE_CURRENT_BINARY_DIR}/include/
us${PROJECT_NAME}Export.h)
46 list(APPEND ${PROJECT_NAME}_PUBLIC_HEADERS
47 ${CMAKE_CURRENT_BINARY_DIR}/include/
us${PROJECT_NAME}Export.h)
49 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/
us${PROJECT_NAME}Config.h.in)
50 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/
us${PROJECT_NAME}Config.h.in
51 ${CMAKE_CURRENT_BINARY_DIR}/include/
us${PROJECT_NAME}Config.h)
52 list(APPEND ${PROJECT_NAME}_PUBLIC_HEADERS
53 ${CMAKE_CURRENT_BINARY_DIR}/include/
us${PROJECT_NAME}Config.h)
56 set(_internal_include_dirs ${${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS})
57 set(${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS )
59 if(_internal_include_dirs)
60 foreach(_internal_include_dir ${_internal_include_dirs})
61 if(IS_ABSOLUTE
"${_internal_include_dir}")
62 list(APPEND ${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS ${_internal_include_dir})
64 list(APPEND ${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${_internal_include_dir})
70 if(CMAKE_VERSION VERSION_LESS 2.8.12)
73 ${${PROJECT_NAME}_INCLUDE_DIRS}
74 ${${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS}
78 #-----------------------------------------------------------------------------
80 #-----------------------------------------------------------------------------
82 # Generate the module init file
83 if(NOT ${PROJECT_NAME}_SKIP_INIT)
87 if(${PROJECT_NAME}_RESOURCES OR ${PROJECT_NAME}_BINARY_RESOURCES)
91 # Create the module library
92 add_library(${${PROJECT_NAME}_TARGET} ${${PROJECT_NAME}_SOURCES}
93 ${${PROJECT_NAME}_PRIVATE_HEADERS} ${${PROJECT_NAME}_PUBLIC_HEADERS})
96 set_property(
TARGET ${${PROJECT_NAME}_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS US_MODULE_NAME=${${PROJECT_NAME}_TARGET})
97 set_property(
TARGET ${${PROJECT_NAME}_TARGET} PROPERTY US_MODULE_NAME ${${PROJECT_NAME}_TARGET})
98 if(NOT US_BUILD_SHARED_LIBS)
99 set_property(
TARGET ${${PROJECT_NAME}_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS US_STATIC_MODULE)
103 if(${PROJECT_NAME}_LINK_FLAGS OR US_LINK_FLAGS)
104 set_target_properties(${${PROJECT_NAME}_TARGET} PROPERTIES
105 LINK_FLAGS
"${US_LINK_FLAGS} ${${PROJECT_NAME}_LINK_FLAGS}"
109 if(CMAKE_VERSION VERSION_GREATER 2.8.11.99)
110 # Currently, public headers include private header files,
111 # so the internal include dirs need to be in the public
112 # include dir section. This needs to be fixed.
113 target_include_directories(${${PROJECT_NAME}_TARGET}
114 PUBLIC ${US_INCLUDE_DIRS} ${${PROJECT_NAME}_INCLUDE_DIRS}
115 PUBLIC ${${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS}
120 set_target_properties(${${PROJECT_NAME}_TARGET} PROPERTIES
121 SOVERSION ${${PROJECT_NAME}_VERSION}
122 PUBLIC_HEADER
"${${PROJECT_NAME}_PUBLIC_HEADERS}"
123 PRIVATE_HEADER
"${${PROJECT_NAME}_PRIVATE_HEADERS}"
126 # Link additional libraries
127 if(${PROJECT_NAME}_LINK_LIBRARIES OR US_LIBRARIES)
128 target_link_libraries(${${PROJECT_NAME}_TARGET} ${US_LIBRARIES} ${${PROJECT_NAME}_LINK_LIBRARIES})
131 # Embed module resources
133 if(${PROJECT_NAME}_RESOURCES OR US_LIBRARIES)
135 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources
136 FILES ${${PROJECT_NAME}_RESOURCES}
137 ZIP_ARCHIVES ${US_LIBRARIES}
140 if(${PROJECT_NAME}_BINARY_RESOURCES)
142 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/resources
143 FILES ${${PROJECT_NAME}_BINARY_RESOURCES}
148 #-----------------------------------------------------------------------------
150 #-----------------------------------------------------------------------------
152 if(NOT US_NO_INSTALL)
153 install(TARGETS ${${PROJECT_NAME}_TARGET}
154 EXPORT
us${PROJECT_NAME}Targets
155 RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} ${US_SDK_INSTALL_COMPONENT}
156 LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} ${US_SDK_INSTALL_COMPONENT}
157 ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR} ${US_SDK_INSTALL_COMPONENT}
158 PUBLIC_HEADER DESTINATION ${HEADER_INSTALL_DIR} ${US_SDK_INSTALL_COMPONENT}
159 PRIVATE_HEADER DESTINATION ${HEADER_INSTALL_DIR} ${US_SDK_INSTALL_COMPONENT})
162 #-----------------------------------------------------------------------------
164 #-----------------------------------------------------------------------------
166 if(US_BUILD_TESTING AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
167 add_subdirectory(
test)
170 #-----------------------------------------------------------------------------
172 #-----------------------------------------------------------------------------
174 if(US_BUILD_TESTING AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/doc/snippets/CMakeLists.txt")
175 # Compile source code snippets
176 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/doc/snippets)
179 #-----------------------------------------------------------------------------
180 # Last configuration and install steps
181 #-----------------------------------------------------------------------------
183 # Version information
185 ${US_CMAKE_DIR}/usModuleConfigVersion.cmake.in
186 ${CppMicroServices_BINARY_DIR}/
us${PROJECT_NAME}ConfigVersion.cmake
190 export(TARGETS ${${PROJECT_NAME}_TARGET} ${US_LIBRARIES}
191 FILE ${CppMicroServices_BINARY_DIR}/
us${PROJECT_NAME}Targets.cmake)
192 if(NOT US_NO_INSTALL)
193 install(EXPORT
us${PROJECT_NAME}Targets
194 FILE
us${PROJECT_NAME}Targets.cmake
195 DESTINATION ${AUXILIARY_CMAKE_INSTALL_DIR})
198 # Configure config file for the build tree
200 set(PACKAGE_CONFIG_INCLUDE_DIR
201 ${${PROJECT_NAME}_INCLUDE_DIRS}
202 ${${PROJECT_NAME}_INTERNAL_INCLUDE_DIRS})
203 set(PACKAGE_CONFIG_RUNTIME_LIBRARY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
206 ${US_CMAKE_DIR}/usModuleConfig.cmake.in
207 ${CppMicroServices_BINARY_DIR}/
us${PROJECT_NAME}Config.cmake
211 # Configure config file
for the install tree
213 if(NOT US_NO_INSTALL)
214 set(CONFIG_INCLUDE_DIR ${HEADER_INSTALL_DIR})
215 set(CONFIG_RUNTIME_LIBRARY_DIR ${RUNTIME_INSTALL_DIR})
217 configure_package_config_file(
218 ${US_CMAKE_DIR}/usModuleConfig.cmake.in
219 ${CppMicroServices_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/
us${PROJECT_NAME}Config.cmake
220 INSTALL_DESTINATION ${AUXILIARY_CMAKE_INSTALL_DIR}
221 PATH_VARS CONFIG_INCLUDE_DIR CONFIG_RUNTIME_LIBRARY_DIR
222 NO_SET_AND_CHECK_MACRO
223 NO_CHECK_REQUIRED_COMPONENTS_MACRO
226 install(FILES ${CppMicroServices_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/
us${PROJECT_NAME}Config.cmake
227 ${CppMicroServices_BINARY_DIR}/
us${PROJECT_NAME}ConfigVersion.cmake
228 DESTINATION ${AUXILIARY_CMAKE_INSTALL_DIR}
229 ${US_SDK_INSTALL_COMPONENT})
232 #-----------------------------------------------------------------------------
234 #-----------------------------------------------------------------------------
236 if(US_BUILD_EXAMPLES AND NOT ${PROJECT_NAME}_SKIP_EXAMPLES AND
237 EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt)
238 set(CppMicroServices_DIR ${CppMicroServices_BINARY_DIR})
239 add_subdirectory(examples)
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
usFunctionAddResources()
Add resources to a library or executable.
usFunctionEmbedResources()
Embed resources in a library or executable.
usMacroCreateModule(_project_name)
usFunctionGetResourceSource()
Get a source file name for handling resource dependencies.
usFunctionGenerateModuleInit(src_var)
Generate a source file which handles proper initialization of a module.