1 ##################################################################
5 #! Creates a module for the automatic module dependency system within MITK.
10 #! mitk_create_module(
11 #! DEPENDS PUBLIC MitkCore
13 #! PRIVATE Qt5|Xml+Networking
14 #! PUBLIC ITK|Watershed
18 #! The <moduleName> parameter specifies the name of the module which is used
19 #! to create a logical target name. The parameter is optional in case the
20 #! MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME variable evaluates to TRUE. The
21 #! module name will then be derived from the directory name in which this
22 #! function is called.
24 #! If set, the following variables will be used to validate the module name:
26 #! MITK_MODULE_NAME_REGEX_MATCH The module name must match this regular expression.
27 #! MITK_MODULE_NAME_REGEX_NOT_MATCH The module name must not match this regular expression.
29 #! If the MITK_MODULE_NAME_PREFIX variable is set, the module name will be prefixed
32 #! A modules source files are specified in a separate CMake file usually
33 #! called files.cmake, located in the module root directory. The
34 #! mitk_create_module() macro evaluates the following CMake variables
35 #! from the files.cmake file:
37 #! - CPP_FILES A list of .cpp files
38 #! - H_FILES A list of .h files without a corresponding .cpp file
39 #! - TXX_FILES A list of .txx files
40 #! - RESOURCE_FILES A list of files (resources) which are embedded into the module
41 #! - MOC_H_FILES A list of Qt header files which should be processed by the MOC
42 #! - UI_FILES A list of .ui Qt UI files
43 #! - QRC_FILES A list of .qrc Qt resource files
44 #! - DOX_FILES A list of .dox Doxygen files
46 #! List of variables available after the function is called:
49 #! - MODULE_IS_ENABLED
50 #! - MODULE_SUBPROJECTS
52 #! \sa mitk_create_executable
54 #! Parameters (all optional):
56 #! \param <moduleName> The module name (also used as target name)
57 #! \param FILES_CMAKE File name of a CMake file setting source list variables
58 #! (defaults to files.cmake)
59 #! \param VERSION Module version number, e.g. "1.2.0"
60 #! \param AUTOLOAD_WITH A module target name identifying the module which will
61 #! trigger the automatic loading of this module
62 #! \param DEPRECATED_SINCE Marks this modules as deprecated since <arg>
63 #! \param DESCRIPTION A description for this module
65 #! Multi-value Parameters (all optional):
67 #! \param SUBPROJECTS List of CDash labels
68 #! \param INCLUDE_DIRS Include directories for this module:
70 #! [[PUBLIC|PRIVATE|INTERFACE] <dir1>...]...
72 #! The default scope for include directories is PUBLIC.
73 #! \param DEPENDS List of module dependencies:
75 #! [[PUBLIC|PRIVATE|INTERFACE] <module1>...]...
77 #! The default scope for module dependencies is PUBLIC.
78 #! \param PACKAGE_DEPENDS List of public packages dependencies (e.g. Qt, VTK, etc.).
79 #! Package dependencies have the following syntax:
81 #! [PUBLIC|PRIVATE|INTERFACE] PACKAGE[|COMPONENT1[+COMPONENT2]...]
83 #! The default scope for package dependencies is PRIVATE.
84 #! \param ADDITIONAL_LIBS List of additional private libraries linked to this module.
85 #! The folder containing the library will be added to the global list of library search paths.
86 #! \param CPP_FILES List of source files for this module. If the list is non-empty,
87 #! the module does not need to provide a files.cmake file or FILES_CMAKE argument.
88 #! \param H_FILES List of public header files for this module. It is recommended to use
89 #! a files.cmake file instead.
93 #! \param FORCE_STATIC Force building this module as a static library
94 #! \param GCC_DEFAULT_VISIBILITY Do not use gcc visibility flags - all
95 #! symbols will be exported
96 #! \param NO_INIT Do not create CppMicroServices initialization code
97 #! \param NO_FEATURE_INFO Do not create a feature info by calling add_feature_info()
98 #! \param WARNINGS_AS_ERRORS Treat compiler warnings as errors
100 ##################################################################
104 VERSION # module version number, e.g.
"1.2.0"
105 EXPORT_DEFINE # export macro name
for public symbols of
this module (
DEPRECATED)
106 AUTOLOAD_WITH # a module target name identifying the module which will trigger the
107 # automatic loading of this module
108 FILES_CMAKE # file name of a
CMake file setting source list variables
109 # (defaults to files.cmake)
110 DEPRECATED_SINCE # marks
this modules as deprecated
111 DESCRIPTION # a description
for this module
114 set(_macro_multiparams
115 SUBPROJECTS # list of CDash labels
116 INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE] <list>
117 INTERNAL_INCLUDE_DIRS # include dirs
internal to
this module (
DEPRECATED)
118 DEPENDS # list of modules
this module depends on: [PUBLIC|PRIVATE|INTERFACE] <list>
119 DEPENDS_INTERNAL # list of modules
this module internally depends on (
DEPRECATED)
120 PACKAGE_DEPENDS
# list of "packages this module depends on (e.g. Qt, VTK, etc.): [PUBLIC|PRIVATE|INTERFACE] <package-list>
121 TARGET_DEPENDS # list of
CMake targets
this module should depend on
122 ADDITIONAL_LIBS # list of addidtional
private libraries linked to
this module.
123 CPP_FILES # list of cpp files
124 H_FILES # list of header files: [PUBLIC|PRIVATE] <list>
128 FORCE_STATIC # force building
this module as a
static library
129 HEADERS_ONLY #
this module is a headers-only library
130 GCC_DEFAULT_VISIBILITY #
do not use gcc visibility flags - all symbols will be exported
131 NO_DEFAULT_INCLUDE_DIRS #
do not add
default include directories like
"include" or
"."
132 NO_INIT #
do not create CppMicroServices initialization code
133 NO_FEATURE_INFO #
do not create a feature
info by calling add_feature_info()
134 WARNINGS_AS_ERRORS # treat all compiler warnings as errors
136 C_MODULE
# compile all source files as C sources
137 CXX_MODULE # compile all source files as C++ sources
140 cmake_parse_arguments(MODULE
"${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN})
142 set(MODULE_NAME ${MODULE_UNPARSED_ARGUMENTS})
144 # -----------------------------------------------------------------
148 if(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME)
149 get_filename_component(MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR}
NAME)
151 message(SEND_ERROR "The module name must not be empty")
155 set(_deprecated_args INTERNAL_INCLUDE_DIRS DEPENDS_INTERNAL EXPORT_DEFINE TARGET_DEPENDS HEADERS_ONLY)
156 foreach(_deprecated_arg ${_deprecated_args})
157 if(MODULE_${_deprecated_arg})
158 message(WARNING
"The ${_deprecated_arg} argument is deprecated")
162 set(_module_type module)
163 set(_Module_type Module)
164 if(MODULE_EXECUTABLE)
165 set(_module_type executable)
166 set(_Module_type Executable)
169 if(MITK_MODULE_NAME_REGEX_MATCH)
170 if(NOT ${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_MATCH})
171 message(SEND_ERROR
"The ${_module_type} name \"${MODULE_NAME}\" does not match the regular expression \"${MITK_MODULE_NAME_REGEX_MATCH}\".")
174 if(MITK_MODULE_NAME_REGEX_NOT_MATCH)
175 if(${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_NOT_MATCH})
176 message(SEND_ERROR
"The ${_module_type} name \"${MODULE_NAME}\" must not match the regular expression \"${MITK_MODULE_NAME_REGEX_NOT_MATCH}\".")
180 if(MITK_MODULE_NAME_PREFIX AND NOT MODULE_NAME MATCHES "^${MITK_MODULE_NAME_PREFIX}.*$
")
181 set(MODULE_NAME "${MITK_MODULE_NAME_PREFIX}${MODULE_NAME}
")
184 if(NOT MODULE_FILES_CMAKE)
185 set(MODULE_FILES_CMAKE files.cmake)
187 if(NOT IS_ABSOLUTE ${MODULE_FILES_CMAKE})
188 set(MODULE_FILES_CMAKE ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE})
191 if(NOT MODULE_SUBPROJECTS)
192 if(MITK_DEFAULT_SUBPROJECTS)
193 set(MODULE_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS})
197 # check if the subprojects exist as targets
198 if(MODULE_SUBPROJECTS)
199 foreach(subproject ${MODULE_SUBPROJECTS})
200 if(NOT TARGET ${subproject})
201 message(SEND_ERROR "The subproject ${subproject} does not have a corresponding target
")
206 # -----------------------------------------------------------------
207 # Check if module should be build
209 set(MODULE_TARGET ${MODULE_NAME})
212 set(MODULE_IS_ENABLED 0)
213 # first we check if we have an explicit module build list
214 if(MITK_MODULES_TO_BUILD)
215 list(FIND MITK_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX)
216 if(_MOD_INDEX EQUAL -1)
217 set(MODULE_IS_EXCLUDED 1)
221 if(NOT MODULE_IS_EXCLUDED)
222 # first of all we check for the dependencies
223 _mitk_parse_package_args(${MODULE_PACKAGE_DEPENDS})
224 mitk_check_module_dependencies(MODULES ${MODULE_DEPENDS}
225 PACKAGES ${PACKAGE_NAMES}
226 MISSING_DEPENDENCIES_VAR _MISSING_DEP
227 PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES)
230 if(MODULE_NO_FEATURE_INFO)
231 message("${_Module_type} ${MODULE_NAME} won
't be built, missing dependency: ${_MISSING_DEP}")
233 set(MODULE_IS_ENABLED 0)
235 set(MODULE_IS_ENABLED 1)
236 # now check for every package if it is enabled. This overlaps a bit with
237 # MITK_CHECK_MODULE ...
238 foreach(_package ${PACKAGE_NAMES})
239 if((DEFINED MITK_USE_${_package}) AND NOT (MITK_USE_${_package}))
240 message("${_Module_type} ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package}
if you want to use it.
")
241 set(MODULE_IS_ENABLED 0)
248 # -----------------------------------------------------------------
249 # Start creating the module
251 if(MODULE_IS_ENABLED)
253 # clear variables defined in files.cmake
263 # clear other variables
264 set(Q${KITNAME}_GENERATED_CPP )
265 set(Q${KITNAME}_GENERATED_MOC_CPP )
266 set(Q${KITNAME}_GENERATED_QRC_CPP )
267 set(Q${KITNAME}_GENERATED_UI_CPP )
269 # check and set-up auto-loading
270 if(MODULE_AUTOLOAD_WITH)
271 if(NOT TARGET "${MODULE_AUTOLOAD_WITH}
")
272 message(SEND_ERROR "The module target \
"${MODULE_AUTOLOAD_WITH}\" specified as the auto-loading module for \"${MODULE_NAME}\" does not exist")
275 set(_module_autoload_meta_target "${CMAKE_PROJECT_NAME}-autoload
")
276 # create a meta-target if it does not already exist
277 if(NOT TARGET ${_module_autoload_meta_target})
278 add_custom_target(${_module_autoload_meta_target})
281 if(NOT MODULE_EXPORT_DEFINE)
282 set(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT)
285 if(MITK_GENERATE_MODULE_DOT)
286 message("MODULEDOTNAME ${MODULE_NAME}
")
287 foreach(dep ${MODULE_DEPENDS})
288 message("MODULEDOT \
"${MODULE_NAME}\" -> \"${dep}\" ; ")
290 endif(MITK_GENERATE_MODULE_DOT)
292 if (EXISTS ${MODULE_FILES_CMAKE})
293 include(${MODULE_FILES_CMAKE})
297 list(APPEND CPP_FILES ${MODULE_CPP_FILES})
300 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src
")
301 # Preprend the "src
" directory to the cpp file list
302 set(_cpp_files ${CPP_FILES})
304 foreach(_cpp_file ${_cpp_files})
305 list(APPEND CPP_FILES "src/${_cpp_file}
")
309 if(CPP_FILES OR RESOURCE_FILES OR UI_FILES OR MOC_H_FILES OR QRC_FILES)
310 set(MODULE_HEADERS_ONLY 0)
312 set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE C)
313 elseif(MODULE_CXX_MODULE)
314 set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE CXX)
317 set(MODULE_HEADERS_ONLY 1)
318 if(MODULE_AUTOLOAD_WITH)
319 message(SEND_ERROR "A headers only module cannot be
auto-loaded
")
324 set(module_c_flags_debug )
325 set(module_c_flags_release )
326 set(module_cxx_flags )
327 set(module_cxx_flags_debug )
328 set(module_cxx_flags_release )
330 if(MODULE_GCC_DEFAULT_VISIBILITY OR NOT CMAKE_COMPILER_IS_GNUCXX)
331 # We only support hidden visibility for gcc for now. Clang still has troubles with
332 # correctly marking template declarations and explicit template instantiations as exported.
333 # See http://comments.gmane.org/gmane.comp.compilers.clang.scm/50028
334 # and http://llvm.org/bugs/show_bug.cgi?id=10113
335 set(CMAKE_CXX_VISIBILITY_PRESET default)
336 set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
338 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
339 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
342 if(MODULE_WARNINGS_AS_ERRORS)
344 mitkFunctionCheckCAndCXXCompilerFlags("/WX
" module_c_flags module_cxx_flags)
346 mitkFunctionCheckCAndCXXCompilerFlags(-Werror module_c_flags module_cxx_flags)
348 # The flag "c++0x-
static-nonintegral-init
" has been renamed in newer Clang
349 # versions to "static-member-init
", see
350 # http://clang-developers.42468.n3.nabble.com/Wc-0x-static-nonintegral-init-gone-td3999651.html
352 # Also, older Clang and seemingly all gcc versions do not warn if unknown
353 # "-no-*
" flags are used, so CMake will happily append any -Wno-* flag to the
354 # command line. This may get confusing if unrelated compiler errors happen and
355 # the error output then additionally contains errors about unknown flags (which
356 # is not the case if there were no compile errors).
358 # So instead of using -Wno-* we use -Wno-error=*, which will be properly rejected by
359 # the compiler and if applicable, prints the specific warning as a real warning and
360 # not as an error (although -Werror was given).
362 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=c++0x-
static-nonintegral-init
" module_c_flags module_cxx_flags)
363 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=
static-member-init
" module_c_flags module_cxx_flags)
364 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=
unknown-warning
" module_c_flags module_cxx_flags)
365 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=gnu
" module_c_flags module_cxx_flags)
366 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=inconsistent-missing-
override" module_c_flags module_cxx_flags)
368 endif(MODULE_WARNINGS_AS_ERRORS)
370 if(MODULE_FORCE_STATIC)
374 endif(MODULE_FORCE_STATIC)
376 if(NOT MODULE_HEADERS_ONLY)
377 if(NOT MODULE_NO_INIT OR RESOURCE_FILES)
378 find_package(CppMicroServices QUIET NO_MODULE REQUIRED)
380 if(NOT MODULE_NO_INIT)
381 usFunctionGenerateModuleInit(CPP_FILES)
384 set(binary_res_files )
385 set(source_res_files )
387 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/resource
")
388 set(res_dir resource)
389 elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Resources
")
390 set(res_dir Resources)
392 message(SEND_ERROR "Resources specified but ${CMAKE_CURRENT_SOURCE_DIR}/resource directory not found.
")
394 foreach(res_file ${RESOURCE_FILES})
395 if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}/${res_file})
396 list(APPEND binary_res_files "${res_file}
")
398 list(APPEND source_res_files "${res_file}
")
402 # Add a source level dependencies on resource files
403 usFunctionGetResourceSource(TARGET ${MODULE_TARGET} OUT CPP_FILES)
409 qt5_wrap_ui(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES})
412 qt5_wrap_cpp(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
415 qt5_add_resources(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES})
419 set(Q${KITNAME}_GENERATED_CPP ${Q${KITNAME}_GENERATED_CPP} ${Q${KITNAME}_GENERATED_UI_CPP} ${Q${KITNAME}_GENERATED_MOC_CPP} ${Q${KITNAME}_GENERATED_QRC_CPP})
421 mitkFunctionOrganizeSources(
428 MOC ${Q${KITNAME}_GENERATED_MOC_CPP}
429 GEN_QRC ${Q${KITNAME}_GENERATED_QRC_CPP}
430 GEN_UI ${Q${KITNAME}_GENERATED_UI_CPP}
434 ${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES}
435 ${TOOL_CPPS} ${TOOL_GUI_CPPS})
437 if(MODULE_SUBPROJECTS)
438 set_property(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK)
441 # ---------------------------------------------------------------
442 # Create the actual module target
444 if(MODULE_HEADERS_ONLY)
445 add_library(${MODULE_TARGET} INTERFACE)
447 if(MODULE_EXECUTABLE)
448 add_executable(${MODULE_TARGET}
449 ${MODULE_CPP_FILES} ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP}
450 ${DOX_FILES} ${UI_FILES} ${QRC_FILES})
451 set(_us_module_name main)
453 add_library(${MODULE_TARGET} ${_STATIC}
454 ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP}
455 ${DOX_FILES} ${UI_FILES} ${QRC_FILES})
456 set(_us_module_name ${MODULE_TARGET})
459 # Apply properties to the module target.
460 target_compile_definitions(${MODULE_TARGET} PRIVATE US_MODULE_NAME=${_us_module_name})
463 string(REPLACE " " ";
" module_c_flags "${module_c_flags}
")
464 target_compile_options(${MODULE_TARGET} PRIVATE ${module_c_flags})
466 if(module_c_flags_debug)
467 string(REPLACE " " ";
" module_c_flags_debug "${module_c_flags_debug}
")
468 target_compile_options(${MODULE_TARGET} PRIVATE $<$<CONFIG:Debug>:${module_c_flags_debug}>)
470 if(module_c_flags_release)
471 string(REPLACE " " ";
" module_c_flags_release "${module_c_flags_release}
")
472 target_compile_options(${MODULE_TARGET} PRIVATE $<$<CONFIG:Release>:${module_c_flags_release}>)
476 string(REPLACE " " ";
" module_cxx_flags "${module_cxx_flags}
")
477 target_compile_options(${MODULE_TARGET} PRIVATE ${module_cxx_flags})
479 if(module_cxx_flags_debug)
480 string(REPLACE " " ";
" module_cxx_flags_debug "${module_cxx_flags_debug}
")
481 target_compile_options(${MODULE_TARGET} PRIVATE $<$<CONFIG:Debug>:${module_cxx_flags_debug}>)
483 if(module_cxx_flags_release)
484 string(REPLACE " " ";
" module_cxx_flags_release "${module_cxx_flags_release}
")
485 target_compile_options(${MODULE_TARGET} PRIVATE $<$<CONFIG:Release>:${module_cxx_flags_release}>)
489 set_property(TARGET ${MODULE_TARGET} PROPERTY US_MODULE_NAME ${_us_module_name})
492 target_link_libraries(${MODULE_TARGET} ssp) # add stack smash protection lib
495 # Add additional library search directories to a global property which
496 # can be evaluated by other CMake macros, e.g. our install scripts.
497 if(MODULE_ADDITIONAL_LIBS)
498 target_link_libraries(${MODULE_TARGET} PRIVATE ${MODULE_ADDITIONAL_LIBS})
499 get_property(_mitk_additional_library_search_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
500 foreach(_lib_filepath ${MODULE_ADDITIONAL_LIBS})
501 get_filename_component(_search_path "${_lib_filepath}
" PATH)
503 list(APPEND _mitk_additional_library_search_paths "${_search_path}
")
506 if(_mitk_additional_library_search_paths)
507 list(REMOVE_DUPLICATES _mitk_additional_library_search_paths)
508 set_property(GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS ${_mitk_additional_library_search_paths})
512 # add the target name to a global property which is used in the top-level
513 # CMakeLists.txt file to export the target
514 set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS ${MODULE_TARGET})
515 if(MODULE_AUTOLOAD_WITH)
516 # for auto-loaded modules, adapt the output directory
517 add_dependencies(${_module_autoload_meta_target} ${MODULE_TARGET})
519 set(_module_output_prop RUNTIME_OUTPUT_DIRECTORY)
521 set(_module_output_prop LIBRARY_OUTPUT_DIRECTORY)
523 set(_module_output_dir ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH})
524 get_target_property(_module_is_imported ${MODULE_AUTOLOAD_WITH} IMPORTED)
525 if(NOT _module_is_imported)
526 # if the auto-loading module is not imported, get its location
527 # and put the auto-load module relative to it.
528 get_target_property(_module_output_dir ${MODULE_AUTOLOAD_WITH} ${_module_output_prop})
529 set_target_properties(${MODULE_TARGET} PROPERTIES
530 ${_module_output_prop} ${_module_output_dir}/${MODULE_AUTOLOAD_WITH})
532 set_target_properties(${MODULE_TARGET} PROPERTIES
533 ${_module_output_prop} ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH})
535 set_target_properties(${MODULE_TARGET} PROPERTIES
536 MITK_AUTOLOAD_DIRECTORY ${MODULE_AUTOLOAD_WITH})
538 # add the auto-load module name as a property
539 set_property(TARGET ${MODULE_AUTOLOAD_WITH} APPEND PROPERTY MITK_AUTOLOAD_TARGETS ${MODULE_TARGET})
543 usFunctionAddResources(TARGET ${MODULE_TARGET}
544 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}
545 FILES ${binary_res_files})
548 usFunctionAddResources(TARGET ${MODULE_TARGET}
549 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${res_dir}
550 FILES ${source_res_files})
552 if(binary_res_files OR source_res_files)
553 usFunctionEmbedResources(TARGET ${MODULE_TARGET})
556 if(MODULE_DEPRECATED_SINCE)
557 set_property(TARGET ${MODULE_TARGET} PROPERTY MITK_MODULE_DEPRECATED_SINCE ${MODULE_DEPRECATED_SINCE})
560 # create export macros
561 if (NOT MODULE_EXECUTABLE)
562 set(_export_macro_name )
563 if(MITK_LEGACY_EXPORT_MACRO_NAME)
564 set(_export_macro_names
565 EXPORT_MACRO_NAME ${MODULE_EXPORT_DEFINE}
566 NO_EXPORT_MACRO_NAME ${MODULE_NAME}_NO_EXPORT
567 DEPRECATED_MACRO_NAME ${MODULE_NAME}_DEPRECATED
568 NO_DEPRECATED_MACRO_NAME ${MODULE_NAME}_NO_DEPRECATED
571 generate_export_header(${MODULE_NAME}
572 ${_export_macro_names}
573 EXPORT_FILE_NAME ${MODULE_NAME}Exports.h
577 target_include_directories(${MODULE_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
581 # ---------------------------------------------------------------
582 # Properties for both header-only and compiled modules
584 if(MODULE_HEADERS_ONLY)
585 set(_module_property_type INTERFACE)
587 set(_module_property_type PUBLIC)
590 if(MODULE_TARGET_DEPENDS)
591 add_dependencies(${MODULE_TARGET} ${MODULE_TARGET_DEPENDS})
594 if(MODULE_SUBPROJECTS AND NOT MODULE_HEADERS_ONLY)
595 set_property(TARGET ${MODULE_TARGET} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK)
596 foreach(subproject ${MODULE_SUBPROJECTS})
597 add_dependencies(${subproject} ${MODULE_TARGET})
601 set(DEPENDS "${MODULE_DEPENDS}
")
602 if(NOT MODULE_NO_INIT AND NOT MODULE_HEADERS_ONLY)
603 # Add a CppMicroServices dependency implicitly, since it is
604 # needed for the generated "module initialization
" code.
605 set(DEPENDS "CppMicroServices;${DEPENDS}
")
607 if(DEPENDS OR MODULE_PACKAGE_DEPENDS)
608 mitk_use_modules(TARGET ${MODULE_TARGET}
610 PACKAGES ${MODULE_PACKAGE_DEPENDS}
614 if(NOT MODULE_C_MODULE)
615 target_compile_features(${MODULE_TARGET} ${_module_property_type} ${MITK_CXX_FEATURES})
618 # add include directories
619 if(MODULE_INTERNAL_INCLUDE_DIRS)
620 target_include_directories(${MODULE_TARGET} PRIVATE ${MODULE_INTERNAL_INCLUDE_DIRS})
622 if(NOT MODULE_NO_DEFAULT_INCLUDE_DIRS)
623 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include)
624 target_include_directories(${MODULE_TARGET} ${_module_property_type} include)
626 target_include_directories(${MODULE_TARGET} ${_module_property_type} .)
628 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src)
629 target_include_directories(${MODULE_TARGET} PRIVATE src)
632 target_include_directories(${MODULE_TARGET} ${_module_property_type} ${MODULE_INCLUDE_DIRS})
636 # -----------------------------------------------------------------
637 # Record missing dependency information
640 if(MODULE_DESCRIPTION)
641 set(MODULE_DESCRIPTION "${MODULE_DESCRIPTION} (missing dependencies: ${_MISSING_DEP})
")
643 set(MODULE_DESCRIPTION "(missing dependencies: ${_MISSING_DEP})
")
646 if(NOT MODULE_NO_FEATURE_INFO)
647 add_feature_info(${MODULE_NAME} MODULE_IS_ENABLED "${MODULE_DESCRIPTION}
")
650 set(MODULE_NAME ${MODULE_NAME} PARENT_SCOPE)
651 set(MODULE_TARGET ${MODULE_TARGET} PARENT_SCOPE)
652 set(MODULE_IS_ENABLED ${MODULE_IS_ENABLED} PARENT_SCOPE)
653 set(MODULE_SUBPROJECTS ${MODULE_SUBPROJECTS} PARENT_SCOPE)
static const unsigned int unknown
Unknown size marker.
static void info(const char *fmt,...)