diff --git a/CMake/mitkFunctionGetGccVersion.cmake b/CMake/mitkFunctionGetGccVersion.cmake index 0d068c44a8..19f1b9a395 100644 --- a/CMake/mitkFunctionGetGccVersion.cmake +++ b/CMake/mitkFunctionGetGccVersion.cmake @@ -1,37 +1,38 @@ ########################################################################### # # Library: CTK # # Copyright (c) Kitware Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.commontk.org/LICENSE # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ########################################################################### +#! \brief Get the gcc version FUNCTION(mitkFunctionGetGccVersion path_to_gcc output_var) IF(CMAKE_COMPILER_IS_GNUCXX) EXECUTE_PROCESS( COMMAND ${path_to_gcc} -dumpversion RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) IF(result) MESSAGE(FATAL_ERROR "Failed to obtain compiler version running [${path_to_gcc} -dumpversion]: ${error}") ENDIF() SET(${output_var} ${output} PARENT_SCOPE) ENDIF() ENDFUNCTION() diff --git a/CMake/mitkFunctionGetVersion.cmake b/CMake/mitkFunctionGetVersion.cmake index 51e7eb20b0..b92ab2a042 100644 --- a/CMake/mitkFunctionGetVersion.cmake +++ b/CMake/mitkFunctionGetVersion.cmake @@ -1,25 +1,28 @@ -# -# Extracts the current git revision hash and branch/tag name -# and provides these in -# MITK_WC_REVISION_HASH -# MITK_WC_REVISION_NAME -# +#! +#! Extracts the current git revision hash and branch/tag name +#! and provides these in ${prefix}_WC_REVISION_HASH and +#! ${prefix}_WC_REVISION_NAME +#! +#! \param source_dir The directory containing a git repository +#! \param prefix A prefix to prepend to the variables containing +#! the revision hash and name. +#! function(mitkFunctionGetVersion source_dir prefix) find_package(Git) if(GIT_FOUND) GIT_WC_INFO(${source_dir} ${prefix}) if(NOT ${prefix}_WC_REVISION_HASH) set(${prefix}_WC_REVISION_HASH "n/a") endif() string(REPLACE " " ";" hash_name ${${prefix}_WC_REVISION_NAME}) list(GET hash_name 1 name) if (NOT name) set(name "n/a") endif() set(${prefix}_WC_REVISION_HASH ${${prefix}_WC_REVISION_HASH} PARENT_SCOPE) set(${prefix}_WC_REVISION_NAME ${name} PARENT_SCOPE) endif() endfunction() diff --git a/CMake/mitkMacroCreateModule.cmake b/CMake/mitkMacroCreateModule.cmake index 24ff53b602..cb67f60561 100644 --- a/CMake/mitkMacroCreateModule.cmake +++ b/CMake/mitkMacroCreateModule.cmake @@ -1,186 +1,190 @@ ################################################################## # # MITK_CREATE_MODULE # -# Creates a module for the automatic module dependeny system within MITK. -# Configurations are generated in the moduleConf directory. -# -# USAGE: -# -# MITK_CREATE_MODULE( -# [INCLUDE_DIRS ] -# [INTERNAL_INCLUDE_DIRS ] -# [DEPENDS ] -# [PROVIDES ] -# [PACKAGE_DEPENDS ] -# [EXPORT_DEFINE ] -# [QT_MODULE] +#! Creates a module for the automatic module dependency system within MITK. +#! Configurations are generated in the moduleConf directory. +#! +#! USAGE: +#! +#! \code +#! MITK_CREATE_MODULE( +#! [INCLUDE_DIRS ] +#! [INTERNAL_INCLUDE_DIRS ] +#! [DEPENDS ] +#! [PROVIDES ] +#! [PACKAGE_DEPENDS ] +#! [EXPORT_DEFINE ] +#! [QT_MODULE] +#! \endcode +#! +#! \param MODULE_NAME_IN The name for the new module # ################################################################## MACRO(MITK_CREATE_MODULE MODULE_NAME_IN) MACRO_PARSE_ARGUMENTS(MODULE "SUBPROJECTS;INCLUDE_DIRS;INTERNAL_INCLUDE_DIRS;DEPENDS;DEPENDS_INTERNAL;PROVIDES;PACKAGE_DEPENDS;EXPORT_DEFINE;ADDITIONAL_LIBS;GENERATED_CPP" "QT_MODULE;FORCE_STATIC;HEADERS_ONLY" ${ARGN}) SET(MODULE_NAME ${MODULE_NAME_IN}) IF(NOT MODULE_SUBPROJECTS) IF(MITK_DEFAULT_SUBPROJECTS) SET(MODULE_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS}) ENDIF() ENDIF() # check if the subprojects exist as targets IF(MODULE_SUBPROJECTS) FOREACH(subproject ${MODULE_SUBPROJECTS}) IF(NOT TARGET ${subproject}) MESSAGE(SEND_ERROR "The subproject ${subproject} does not have a corresponding target") ENDIF() ENDFOREACH() ENDIF() # assume worst case SET(MODULE_IS_ENABLED 0) # first of all we check for the dependencies MITK_CHECK_MODULE(_MISSING_DEP ${MODULE_DEPENDS}) IF(_MISSING_DEP) MESSAGE("Module ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") SET(MODULE_IS_ENABLED 0) ELSE(_MISSING_DEP) SET(MODULE_IS_ENABLED 1) # now check for every package if it is enabled. This overlaps a bit with # MITK_CHECK_MODULE ... FOREACH(_package ${MODULE_PACKAGE_DEPENDS}) IF((DEFINED MITK_USE_${_package}) AND NOT (MITK_USE_${_package})) MESSAGE("Module ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package} if you want to use it.") SET(MODULE_IS_ENABLED 0) ENDIF() ENDFOREACH() IF(MODULE_IS_ENABLED) IF(NOT MODULE_QT_MODULE OR MITK_USE_QT) SET(MODULE_IS_ENABLED 1) _MITK_CREATE_MODULE_CONF() IF(NOT MODULE_EXPORT_DEFINE) SET(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT) ENDIF(NOT MODULE_EXPORT_DEFINE) CONFIGURE_FILE(${MITK_SOURCE_DIR}/CMake/moduleExports.h.in ${MITK_MODULES_CONF_DIR}/${MODULE_NAME}Exports.h @ONLY) IF(MITK_GENERATE_MODULE_DOT) MESSAGE("MODULEDOTNAME ${MODULE_NAME}") FOREACH(dep ${MODULE_DEPENDS}) MESSAGE("MODULEDOT \"${MODULE_NAME}\" -> \"${dep}\" ; ") ENDFOREACH(dep) ENDIF(MITK_GENERATE_MODULE_DOT) SET(DEPENDS "${MODULE_DEPENDS}") SET(DEPENDS_BEFORE "not initialized") SET(PACKAGE_DEPENDS "${MODULE_PACKAGE_DEPENDS}") MITK_USE_MODULE("${MODULE_DEPENDS}") # ok, now create the module itself INCLUDE_DIRECTORIES(. ${ALL_INCLUDE_DIRECTORIES}) INCLUDE(files.cmake) IF(NOT MODULE_QT_MODULE) ORGANIZE_SOURCES(SOURCE ${CPP_FILES} HEADER ${H_FILES} TXX ${TXX_FILES} DOC ${DOX_FILES} ) IF(MODULE_FORCE_STATIC) SET(_STATIC ${MITK_WIN32_FORCE_STATIC}) ENDIF(MODULE_FORCE_STATIC) SET(coverage_sources ${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES} ${TOOL_CPPS}) IF(MODULE_SUBPROJECTS) SET_PROPERTY(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) ENDIF() IF(NOT MODULE_HEADERS_ONLY) IF(ALL_LIBRARY_DIRS) # LINK_DIRECTORIES applies only to targets which are added after the call to LINK_DIRECTORIES LINK_DIRECTORIES(${ALL_LIBRARY_DIRS}) ENDIF(ALL_LIBRARY_DIRS) ADD_LIBRARY(${MODULE_PROVIDES} ${_STATIC} ${coverage_sources} ${CPP_FILES_GENERATED} ${DOX_FILES} ${UI_FILES}) IF(MODULE_SUBPROJECTS) SET_PROPERTY(TARGET ${MODULE_PROVIDES} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) FOREACH(subproject ${MODULE_SUBPROJECTS}) ADD_DEPENDENCIES(${subproject} ${MODULE_PROVIDES}) ENDFOREACH() ENDIF() IF(ALL_LIBRARIES) TARGET_LINK_LIBRARIES(${MODULE_PROVIDES} ${ALL_LIBRARIES}) ENDIF(ALL_LIBRARIES) ENDIF() ELSE(NOT MODULE_QT_MODULE) INCLUDE(files.cmake) IF(UI_FILES) QT4_WRAP_UI(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES}) ENDIF(UI_FILES) IF(MOC_H_FILES) QT4_WRAP_CPP(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES}) ENDIF(MOC_H_FILES) IF(QRC_FILES) QT4_ADD_RESOURCES(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES}) ENDIF(QRC_FILES) SET(Q${KITNAME}_GENERATED_CPP ${Q${KITNAME}_GENERATED_CPP} ${Q${KITNAME}_GENERATED_UI_CPP} ${Q${KITNAME}_GENERATED_MOC_CPP} ${Q${KITNAME}_GENERATED_QRC_CPP}) ORGANIZE_SOURCES(SOURCE ${CPP_FILES} HEADER ${H_FILES} TXX ${TXX_FILES} DOC ${DOX_FILES} UI ${UI_FILES} QRC ${QRC_FILES} MOC ${Q${KITNAME}_GENERATED_MOC_CPP} GEN_QRC ${Q${KITNAME}_GENERATED_QRC_CPP} GEN_UI ${Q${KITNAME}_GENERATED_UI_CPP}) # MITK_GENERATE_TOOLS_LIBRARY(Qmitk${LIBPOSTFIX} "NO") SET(coverage_sources ${CPP_FILES} ${CORRESPONDING__H_FILES} ${GLOBBED__H_FILES} ${TXX_FILES} ${TOOL_GUI_CPPS}) SET_PROPERTY(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS}) IF(NOT MODULE_HEADERS_ONLY) IF(ALL_LIBRARY_DIRS) # LINK_DIRECTORIES applies only to targets which are added after the call to LINK_DIRECTORIES LINK_DIRECTORIES(${ALL_LIBRARY_DIRS}) ENDIF(ALL_LIBRARY_DIRS) ADD_LIBRARY(${MODULE_PROVIDES} ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP} ${DOX_FILES} ${UI_FILES} ${QRC_FILES}) TARGET_LINK_LIBRARIES(${MODULE_PROVIDES} ${QT_LIBRARIES} ${ALL_LIBRARIES} QVTK) IF(MODULE_SUBPROJECTS) SET_PROPERTY(TARGET ${MODULE_PROVIDES} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) FOREACH(subproject ${MODULE_SUBPROJECTS}) ADD_DEPENDENCIES(${subproject} ${MODULE_PROVIDES}) ENDFOREACH() ENDIF() ENDIF() ENDIF(NOT MODULE_QT_MODULE) #IF(NOT MODULE_HEADERS_ONLY AND TARGET EP_MITK) # ADD_DEPENDENCIES(${MODULE_PROVIDES} EP_MITK) #ENDIF() # install only if shared lib (for now) IF(NOT _STATIC OR MINGW) IF(NOT MODULE_HEADERS_ONLY) # # deprecated: MITK_INSTALL_TARGETS(${MODULE_PROVIDES}) ENDIF() ENDIF(NOT _STATIC OR MINGW) ENDIF(NOT MODULE_QT_MODULE OR MITK_USE_QT) ENDIF(MODULE_IS_ENABLED) ENDIF(_MISSING_DEP) IF(NOT MODULE_IS_ENABLED) _MITK_CREATE_MODULE_CONF() ENDIF(NOT MODULE_IS_ENABLED) ENDMACRO(MITK_CREATE_MODULE) diff --git a/CMake/mitkMacroInstallHelperApp.cmake b/CMake/mitkMacroInstallHelperApp.cmake index 30b6ec13c2..5a18902d09 100644 --- a/CMake/mitkMacroInstallHelperApp.cmake +++ b/CMake/mitkMacroInstallHelperApp.cmake @@ -1,110 +1,110 @@ -# MITK specific cross plattform install macro -# -# Usage: MITK_INSTALL_HELPER_APP(target1 [target2] ....) -# +#! MITK specific cross plattform install macro +#! +#! Usage: MITK_INSTALL_HELPER_APP(target1 [target2] ....) +#! MACRO(MITK_INSTALL_HELPER_APP) MACRO_PARSE_ARGUMENTS(_install "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" "GLOB_PLUGINS" ${ARGN}) LIST(APPEND _install_TARGETS ${_install_DEFAULT_ARGS}) # TODO: how to supply to correct intermediate directory?? # CMAKE_CFG_INTDIR is not expanded to actual values inside the INSTALL(CODE "...") macro ... SET(intermediate_dir ) IF(WIN32 AND NOT MINGW) SET(intermediate_dir Release) ENDIF() SET(DIRS ${VTK_RUNTIME_LIBRARY_DIRS}/${intermediate_dir} ${ITK_LIBRARY_DIRS}/${intermediate_dir} ${QT_LIBRARY_DIR} ${QT_LIBRARY_DIR}/../bin ${MITK_BINARY_DIR}/bin/${intermediate_dir} ${_install_LIBRARY_DIRS} ) IF(APPLE) LIST(APPEND DIRS "/usr/lib") ENDIF(APPLE) if(QT_LIBRARY_DIR MATCHES "^(/lib/|/lib32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/lib64/|/usr/X11R6/)") set(_qt_is_system_qt 1) endif() FOREACH(_target ${_install_EXECUTABLES}) SET(_qt_plugins_install_dirs "") SET(_qt_conf_install_dirs "") SET(_target_locations "") GET_FILENAME_COMPONENT(_target_name ${_target} NAME) IF(APPLE) IF(NOT MACOSX_BUNDLE_NAMES) SET(_qt_conf_install_dirs bin) SET(_target_locations bin/${_target_name}) SET(${_target_locations}_qt_plugins_install_dir bin) INSTALL(PROGRAMS ${_target} DESTINATION bin) ELSE() FOREACH(bundle_name ${MACOSX_BUNDLE_NAMES}) LIST(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources) SET(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target_name}) LIST(APPEND _target_locations ${_current_target_location}) SET(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) INSTALL(PROGRAMS ${_target} DESTINATION ${bundle_name}.app/Contents/MacOS/) ENDFOREACH() ENDIF(NOT MACOSX_BUNDLE_NAMES) ELSE() SET(_target_locations bin/${_target_name}) SET(${_target_locations}_qt_plugins_install_dir bin) SET(_qt_conf_install_dirs bin) INSTALL(PROGRAMS ${_target} DESTINATION bin) ENDIF() FOREACH(_target_location ${_target_locations}) IF(NOT _qt_is_system_qt) IF(QT_PLUGINS_DIR) IF(WIN32) INSTALL(DIRECTORY "${QT_PLUGINS_DIR}" DESTINATION ${${_target_location}_qt_plugins_install_dir} CONFIGURATIONS Release FILES_MATCHING REGEX "[^4d]4?${CMAKE_SHARED_LIBRARY_SUFFIX}" ) INSTALL(DIRECTORY "${QT_PLUGINS_DIR}" DESTINATION ${${_target_location}_qt_plugins_install_dir} CONFIGURATIONS Debug FILES_MATCHING REGEX "d4?${CMAKE_SHARED_LIBRARY_SUFFIX}" ) ELSE(WIN32) # install everything, see bug 7143 INSTALL(DIRECTORY "${QT_PLUGINS_DIR}" DESTINATION ${${_target_location}_qt_plugins_install_dir} FILES_MATCHING REGEX "${CMAKE_SHARED_LIBRARY_SUFFIX}" ) ENDIF(WIN32) ENDIF() ENDIF() _fixup_target() ENDFOREACH(_target_location) IF(NOT _qt_is_system_qt) #-------------------------------------------------------------------------------- # install a qt.conf file # this inserts some cmake code into the install script to write the file SET(_qt_conf_plugin_install_prefix .) IF(APPLE) SET(_qt_conf_plugin_install_prefix ./MacOS) ENDIF() FOREACH(_qt_conf_install_dir ${_qt_conf_install_dirs}) INSTALL(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \" [Paths] Prefix=${_qt_conf_plugin_install_prefix} \")") ENDFOREACH() ENDIF() ENDFOREACH() ENDMACRO(MITK_INSTALL_HELPER_APP)