2 #! \brief Creates a MITK CTK plugin.
4 #! This function should be called from the plugins CMakeLists.txt file.
5 #! The target name is available after the macro call as ${PLUGIN_TARGET}
6 #! to add additional libraries in your CMakeLists.txt. Include paths and link
7 #! libraries are set depending on the value of the Required-Plugins header
8 #! in your manifest_headers.cmake file.
10 #! This function internally calls ctkMacroBuildPlugin() and adds support
11 #! for Qt Help files and installers.
14 #! \param TEST_PLUGIN Mark this plug-in as a testing plug-in.
15 #! \param NO_INSTALL Don't install this plug-in.
19 #! \param EXPORT_DIRECTIVE (required) The export directive to use in the generated
20 #! <plugin_target>_Exports.h file.
22 #! Multi-value parameters (all optional):
24 #! \param EXPORTED_INCLUDE_SUFFIXES A list of sub-directories which should
25 #! be added to the current source directory. The resulting directories
26 #! will be available in the set of include directories of depending plug-ins.
27 #! \param MODULE_DEPENDS (optional) A list of Modules this plug-in depends on.
28 #! \param PACKAGE_DEPENDS (optional) A list of external packages this plug-in depends on.
29 #! \param DOXYGEN_TAGFILES (optional) Which external tag files should be available for the plugin documentation
30 #! \param MOC_OPTIONS (optional) Additional options to pass to the Qt MOC compiler
35 TEST_PLUGIN # Mark
this plug-
in as a testing plug-
in
36 NO_INSTALL # Don
't install this plug-in
40 # single value arguments
42 EXPORT_DIRECTIVE # (required) TODO: could be generated via CMake as it is done for MITK modules already
45 # multiple value arguments
47 EXPORTED_INCLUDE_SUFFIXES # (optional) additional public include directories
48 MODULE_DEPENDS # (optional)
55 cmake_parse_arguments(_PLUGIN "${arg_options}" "${arg_single}" "${arg_multiple}" ${ARGN})
57 if(_PLUGIN_TEST_PLUGIN)
58 set(_PLUGIN_NO_INSTALL 1)
59 set(is_test_plugin "TEST_PLUGIN")
64 set(_PLUGIN_MOC_OPTIONS "-DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED ${_PLUGIN_MOC_OPTIONS}")
66 set(PLUGIN_TARGET ${PROJECT_NAME})
68 mitk_check_module_dependencies(MODULES ${_PLUGIN_MODULE_DEPENDS}
69 PACKAGES ${_PLUGIN_PACKAGE_DEPENDS}
70 MISSING_DEPENDENCIES_VAR _missing_deps
71 MODULE_DEPENDENCIES_VAR _module_deps
72 PACKAGE_DEPENDENCIES_VAR _package_deps)
75 if(NOT MITK_BUILD_ALL_PLUGINS)
76 message(SEND_ERROR "${PROJECT_NAME} is missing requirements and won't be built. Missing: ${_missing_deps}
")
78 message(STATUS "${PROJECT_NAME} is missing requirements and won
't be built. Missing: ${_missing_deps}")
83 # -------------- All dependencies are resolved ------------------
85 message(STATUS "Creating CTK plugin ${PROJECT_NAME}")
89 set(_PLUGIN_CPP_FILES ${CPP_FILES})
90 set(_PLUGIN_MOC_H_FILES ${MOC_H_FILES})
91 set(_PLUGIN_UI_FILES ${UI_FILES})
92 set(_PLUGIN_CACHED_RESOURCE_FILES ${CACHED_RESOURCE_FILES})
93 set(_PLUGIN_TRANSLATION_FILES ${TRANSLATION_FILES})
94 set(_PLUGIN_QRC_FILES ${QRC_FILES})
95 set(_PLUGIN_H_FILES ${H_FILES})
96 set(_PLUGIN_TXX_FILES ${TXX_FILES})
97 set(_PLUGIN_DOX_FILES ${DOX_FILES})
98 set(_PLUGIN_CMAKE_FILES ${CMAKE_FILES} files.cmake)
99 set(_PLUGIN_FILE_DEPENDENCIES ${FILE_DEPENDENCIES})
101 if(CTK_PLUGINS_OUTPUT_DIR)
102 set(_output_dir "${CTK_PLUGINS_OUTPUT_DIR}")
107 # Compute the plugin dependencies
108 ctkFunctionGetTargetLibraries(_PLUGIN_target_libraries "")
110 #------------------------------------------------------------#
111 #------------------ Qt Help support -------------------------#
113 set(PLUGIN_GENERATED_QCH_FILES )
114 if(BLUEBERRY_USE_QT_HELP AND
115 EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual")
116 set(PLUGIN_DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual")
117 set(PLUGIN_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/documentation/UserManual")
119 # Create a list of Doxygen tag files from the plug-in dependencies
120 set(PLUGIN_DOXYGEN_TAGFILES)
121 foreach(_dep_target ${_PLUGIN_target_libraries})
122 string(REPLACE _ . _dep ${_dep_target})
124 get_target_property(_is_imported ${_dep_target} IMPORTED)
126 get_target_property(_import_loc_debug ${_dep_target} IMPORTED_LOCATION_DEBUG)
127 get_target_property(_import_loc_release ${_dep_target} IMPORTED_LOCATION_RELEASE)
128 # There is not necessarily a debug and release build
129 if(_import_loc_release)
130 set(_import_loc ${_import_loc_release})
132 set(_import_loc ${_import_loc_debug})
134 get_filename_component(_target_filename "${_import_loc}" NAME)
135 # on windows there might be a Debug or Release subdirectory
136 string(REGEX REPLACE "/bin/plugins/(Debug/|Release/)?${_target_filename}" "/Plugins/${_dep}/documentation/UserManual" plugin_tag_dir "${_import_loc}" )
138 set(plugin_tag_dir "${CMAKE_BINARY_DIR}/Plugins/${_dep}/documentation/UserManual")
141 set(_tag_file "${plugin_tag_dir}/${_dep_target}.tag")
142 if(EXISTS ${_tag_file})
143 set(PLUGIN_DOXYGEN_TAGFILES "${PLUGIN_DOXYGEN_TAGFILES} \"${_tag_file}=qthelp://${_dep}/bundle/\"")
146 if(_PLUGIN_DOXYGEN_TAGFILES)
147 set(PLUGIN_DOXYGEN_TAGFILES "${PLUGIN_DOXYGEN_TAGFILES} ${_PLUGIN_DOXYGEN_TAGFILES}")
149 #message("PLUGIN_DOXYGEN_TAGFILES: ${PLUGIN_DOXYGEN_TAGFILES}")
151 if(_PLUGIN_NO_QHP_TRANSFORM)
156 _FUNCTION_CREATE_CTK_QT_COMPRESSED_HELP(PLUGIN_GENERATED_QCH_FILES ${_use_qhp_xsl})
157 list(APPEND _PLUGIN_CACHED_RESOURCE_FILES ${PLUGIN_GENERATED_QCH_FILES})
160 #------------------------------------------------------------#
161 #------------------ Create Plug-in --------------------------#
163 mitkFunctionOrganizeSources(
164 SOURCE ${_PLUGIN_CPP_FILES}
165 HEADER ${_PLUGIN_H_FILES}
166 TXX ${_PLUGIN_TXX_FILES}
167 DOC ${_PLUGIN_DOX_FILES}
168 UI ${_PLUGIN_UI_FILES}
169 QRC ${_PLUGIN_QRC_FILES} ${_PLUGIN_CACHED_RESOURCE_FILES}
170 META ${_PLUGIN_META_FILES}
173 GEN_QRC ${MY_QRC_SRCS}
177 NAME ${PLUGIN_TARGET}
178 EXPORT_DIRECTIVE ${_PLUGIN_EXPORT_DIRECTIVE}
179 SRCS ${_PLUGIN_CPP_FILES} ${_PLUGIN_H_FILES} ${CORRESPONDING__H_FILES} ${GLOBBED__H_FILES}
180 MOC_SRCS ${_PLUGIN_MOC_H_FILES}
181 MOC_OPTIONS ${_PLUGIN_MOC_OPTIONS}
182 UI_FORMS ${_PLUGIN_UI_FILES}
183 EXPORTED_INCLUDE_SUFFIXES ${_PLUGIN_EXPORTED_INCLUDE_SUFFIXES}
184 RESOURCES ${_PLUGIN_QRC_FILES}
185 TARGET_LIBRARIES ${_PLUGIN_target_libraries}
186 CACHED_RESOURCEFILES ${_PLUGIN_CACHED_RESOURCE_FILES}
187 TRANSLATIONS ${_PLUGIN_TRANSLATION_FILES}
188 OUTPUT_DIR ${_output_dir}
189 NO_INSTALL # we install the plug-in ourselves
193 mitk_use_modules(TARGET ${PLUGIN_TARGET}
194 MODULES ${_PLUGIN_MODULE_DEPENDS}
195 PACKAGES ${_PLUGIN_PACKAGE_DEPENDS}
198 set_property(TARGET ${PLUGIN_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS US_MODULE_NAME=${PLUGIN_TARGET})
199 set_property(TARGET ${PLUGIN_TARGET} PROPERTY US_MODULE_NAME ${PLUGIN_TARGET})
201 if(MITK_DEFAULT_SUBPROJECTS AND NOT MY_SUBPROJECTS)
202 set(MY_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS})
206 set_property(TARGET ${PLUGIN_TARGET} PROPERTY LABELS ${MY_SUBPROJECTS})
207 foreach(subproject ${MY_SUBPROJECTS})
208 add_dependencies(${subproject} ${PLUGIN_TARGET})
212 if(_PLUGIN_TEST_PLUGIN)
213 find_package(CppUnit REQUIRED)
214 target_include_directories(${PLUGIN_TARGET} PRIVATE ${CppUnit_INCLUDE_DIRS})
215 target_link_libraries(${PLUGIN_TARGET} PRIVATE ${CppUnit_LIBRARIES})
219 target_link_libraries(${PLUGIN_TARGET} PRIVATE mbilog)
222 set(_PLUGIN_META_FILES "${CMAKE_CURRENT_SOURCE_DIR}/manifest_headers.cmake")
223 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml")
224 list(APPEND _PLUGIN_META_FILES "${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml")
227 set(PLUGIN_TARGET ${PLUGIN_TARGET} PARENT_SCOPE)
229 #------------------------------------------------------------#
230 #------------------ Installer support -----------------------#
231 if(NOT _PLUGIN_NO_INSTALL)
232 set(install_directories "")
233 if(NOT MACOSX_BUNDLE_NAMES)
234 set(install_directories bin/plugins)
235 else(NOT MACOSX_BUNDLE_NAMES)
236 foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
237 list(APPEND install_directories ${bundle_name}.app/Contents/MacOS/plugins)
238 endforeach(bundle_name)
239 endif(NOT MACOSX_BUNDLE_NAMES)
241 foreach(install_subdir ${install_directories})
243 mitkFunctionInstallCTKPlugin(TARGETS ${PLUGIN_TARGET}
244 DESTINATION ${install_subdir})
248 set(_autoload_targets )
249 foreach(_dependency ${_module_deps})
250 get_target_property(_dep_autoloads ${_dependency} MITK_AUTOLOAD_TARGETS)
252 list(APPEND _autoload_targets ${_dep_autoloads})
256 # The MITK_AUTOLOAD_TARGETS property is used in the mitkFunctionInstallAutoLoadModules
257 # macro which expects a list of plug-in targets.
258 if (_autoload_targets)
259 list(REMOVE_DUPLICATES _autoload_targets)
260 set_target_properties(${PLUGIN_TARGET} PROPERTIES MITK_AUTOLOAD_TARGETS "${_autoload_targets}")
267 function(_FUNCTION_CREATE_CTK_QT_COMPRESSED_HELP qch_file use_xsl)
269 set(_manifest_path "${CMAKE_CURRENT_SOURCE_DIR}/manifest_headers.cmake")
270 if(NOT EXISTS ${_manifest_path})
271 message(FATAL_ERROR "${_manifest_path} not found")
274 include(${_manifest_path})
275 string(REPLACE "_" "." Plugin-SymbolicName "${PLUGIN_TARGET}")
277 configure_file(${MITK_SOURCE_DIR}/Documentation/doxygen_plugin_manual.conf.in
278 ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf
281 set(_qhp_xsl_file "${MITK_SOURCE_DIR}/Documentation/qhp_toc.xsl")
282 set(_generated_qhp_file "${PLUGIN_DOXYGEN_OUTPUT_DIR}/html/index.qhp")
283 set(_transformed_qhp_file "${PLUGIN_DOXYGEN_OUTPUT_DIR}/html/${PLUGIN_TARGET}.qhp")
284 set(${qch_file} "${CMAKE_CURRENT_BINARY_DIR}/resources/${PLUGIN_TARGET}.qch")
288 set(_xsl_command COMMAND ${QT_XMLPATTERNS_EXECUTABLE} ${_qhp_xsl_file} ${_generated_qhp_file} -output ${_transformed_qhp_file})
291 file(GLOB _file_dependencies "${PLUGIN_DOXYGEN_INPUT_DIR}/*")
293 add_custom_command(OUTPUT ${${qch_file}}
294 # Generate a Qt help project (index.qhp) with doxygen
295 COMMAND ${DOXYGEN_EXECUTABLE} ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf
296 # Use a XSL transformation to get rid of the top-level entry
298 # Generate the final Qt compressed help file (.qch)
299 COMMAND ${QT_HELPGENERATOR_EXECUTABLE} ${_transformed_qhp_file} -o ${${qch_file}}
300 DEPENDS ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf ${_file_dependencies}
303 #set_source_files_properties(${qch_file} PROPERTIES GENERATED 1)
305 set(${qch_file} ${${qch_file}} PARENT_SCOPE)
309 function(MACRO_CREATE_MITK_CTK_PLUGIN)
310 message(SEND_ERROR "The function MACRO_CREATE_MITK_CTK_PLUGIN was renamed to mitk_create_plugin in MITK 2015.05.")
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
mitk_create_plugin()
Creates a MITK CTK plugin.