diff --git a/BlueBerry/CMake/MacroCreatePlugin.cmake b/BlueBerry/CMake/MacroCreatePlugin.cmake index ba23779fa5..39c2b81f61 100755 --- a/BlueBerry/CMake/MacroCreatePlugin.cmake +++ b/BlueBerry/CMake/MacroCreatePlugin.cmake @@ -1,202 +1,206 @@ # MACRO_CREATE_PLUGIN() # # Creates the current plugin. # This macro should be called from the plugins CMakeLists.txt file. The plugin # library is build in a subdirectory of PLUGIN_OUTPUT_DIR, which is derived from # the variable PLUGIN_OUTPUT_BASE_DIR coming from COLLECT_PLUGINS(). # The target name is available as PLUGIN_TARGET # to add additional libraries in your CMakeLists.txt. Include paths and link # libraries are set depending on the value of the Required-Bundles header # in your plugins MANIFEST.MF file. # # Available variables: # # - PLUGIN_OUTPUT_DIR the binary output directory of your plugin # - PLUGIN_TARGET the target name of your plugins dll # # MACRO(MACRO_CREATE_PLUGIN) IF(MSVC80) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) ENDIF(MSVC80) MESSAGE(STATUS "Creating plugin ${BUNDLE-SYMBOLICNAME}") PROJECT(${BUNDLE-SYMBOLICNAME}) STRING(REPLACE . _ PLUGIN_TARGET ${BUNDLE-SYMBOLICNAME}) SET(PLUGIN_OUTPUT_DIR ${${BUNDLE-SYMBOLICNAME}_OUT_DIR}) FILE(MAKE_DIRECTORY ${PLUGIN_OUTPUT_DIR}) INCLUDE(files.cmake) SET(PLUGIN_CPP_FILES ${CPP_FILES}) SET(PLUGIN_MOC_H_FILES ${MOC_H_FILES}) SET(PLUGIN_UI_FILES ${UI_FILES}) SET(PLUGIN_RESOURCE_FILES ${RESOURCE_FILES}) SET(PLUGIN_RES_FILES ${RES_FILES}) SET(PLUGIN_H_FILES ${H_FILES}) SET(PLUGIN_TXX_FILES ${TXX_FILES}) SET(PLUGIN_DOX_FILES ${DOX_FILES}) SET(PLUGIN_CMAKE_FILES ${CMAKE_FILES} files.cmake) SET(PLUGIN_FILE_DEPENDENCIES ${FILE_DEPENDENCIES}) # Copy the META-INF directory into the binary output dir SET (PLUGIN_META_FILES ${PLUGIN_META_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/META-INF/MANIFEST.MF) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/META-INF/MANIFEST.MF ${PLUGIN_OUTPUT_DIR}/META-INF/MANIFEST.MF COPYONLY) # Copy the plugin.xml into the binary output dir SET(PLUGINXML ${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml) IF(EXISTS ${PLUGINXML}) SET (PLUGIN_META_FILES ${PLUGIN_META_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml) CONFIGURE_FILE(${PLUGINXML} ${PLUGIN_OUTPUT_DIR}/plugin.xml COPYONLY) ENDIF(EXISTS ${PLUGINXML}) # Copy the resource files into the binary output dir FOREACH(_resource ${PLUGIN_RESOURCE_FILES}) CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/${_resource}" "${PLUGIN_OUTPUT_DIR}/${_resource}" COPYONLY) ENDFOREACH(_resource ${PLUGIN_RESOURCE_FILES}) SET(PLUGIN_GENERATED_UI_FILES ) IF(PLUGIN_UI_FILES) QT4_WRAP_UI(PLUGIN_GENERATED_UI_FILES ${PLUGIN_UI_FILES}) ENDIF(PLUGIN_UI_FILES) SET(PLUGIN_GENERATED_MOC_FILES ) IF(PLUGIN_MOC_H_FILES) # this is a workaround for Visual Studio. The relative include paths in the generated # moc files can get very long and can't be resolved by the MSVC compiler. See bug #1961 # for details. FOREACH(moc_h_file ${PLUGIN_MOC_H_FILES}) QT4_WRAP_CPP(PLUGIN_GENERATED_MOC_FILES ${moc_h_file} OPTIONS -f${moc_h_file}) ENDFOREACH(moc_h_file) ENDIF(PLUGIN_MOC_H_FILES) SET(PLUGIN_GENERATED_QRC_FILES ) IF(PLUGIN_RES_FILES) QT4_ADD_RESOURCES(PLUGIN_GENERATED_QRC_FILES ${PLUGIN_RES_FILES}) ENDIF(PLUGIN_RES_FILES) #------------------------------------------------------------# #------------------ Qt Help support -------------------------# SET(PLUGIN_GENERATED_QCH_FILES ) IF (BLUEBERRY_USE_QT_HELP AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual") SET(PLUGIN_DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual") SET(PLUGIN_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/documentation/UserManual") _MACRO_CREATE_QT_COMPRESSED_HELP(PLUGIN_GENERATED_QCH_FILES ) ENDIF() INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}) _MACRO_SETUP_PLUGIN_DEPENDENCIES(_linklibs) MACRO_ORGANIZE_SOURCES(SOURCE ${PLUGIN_CPP_FILES} HEADER ${PLUGIN_H_FILES} TXX ${PLUGIN_TXX_FILES} DOC ${PLUGIN_DOX_FILES} UI ${PLUGIN_UI_FILES} QRC ${PLUGIN_RES_FILES} META ${PLUGIN_META_FILES} MOC ${PLUGIN_GENERATED_MOC_FILES} GEN_UI ${PLUGIN_GENERATED_UI_FILES} GEN_QRC ${PLUGIN_GENERATED_QRC_FILES}) SET(_all_target_files ${PLUGIN_CPP_FILES} ${PLUGIN_H_FILES} ${PLUGIN_TXX_FILES} ${PLUGIN_DOX_FILES} ${PLUGIN_UI_FILES} ${PLUGIN_RES_FILES} ${PLUGIN_META_FILES} ${PLUGIN_GENERATED_MOC_FILES} ${PLUGIN_GENERATED_UI_FILES} ${PLUGIN_GENERATED_QRC_FILES} ${PLUGIN_GENERATED_QCH_FILES} ${PLUGIN_CMAKE_FILES} ${CORRESPONDING__H_FILES} ${GLOBBED__H_FILES} ${PLUGIN_FILE_DEPENDENCIES} ) ADD_LIBRARY(${PLUGIN_TARGET} ${_all_target_files}) SET(PLUGIN_TARGETS ${PLUGIN_TARGETS} ${PLUGIN_TARGET} CACHE INTERNAL "Temporary list of plug-in targets") SET_TARGET_PROPERTIES(${PLUGIN_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}/bin" LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}/bin" ARCHIVE_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}/bin" DEBUG_POSTFIX ${BLUEBERRY_DEBUG_POSTFIX}) IF(mbilog_FOUND) TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} mbilog) ENDIF() # we need to explicitly state the debug versions of the libraries # we are linking to in the TARGET_LINK_LIBRARIES command. # Although we set the debug postfix to d, CMake automatically # appends it in a TARGET_LINK_LIBRARIES(target lib1) command only # if lib1 has been build within the same project. # External projects using this macro would therefore always link # to lib1, instead of lib1d in debug configurations SET(_debug_linklibs "") FOREACH(_linklib ${PLUGIN_LINK_LIBRARIES}) SET(_debug_linklibs ${_debug_linklibs} optimized "${_linklib}" debug "${_linklib}${BLUEBERRY_DEBUG_POSTFIX}") ENDFOREACH(_linklib) TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ${_debug_linklibs}) TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized "PocoFoundation" debug "PocoFoundation${BLUEBERRY_DEBUG_POSTFIX}" optimized "PocoUtil" debug "PocoUtil${BLUEBERRY_DEBUG_POSTFIX}" optimized "PocoXML" debug "PocoXML${BLUEBERRY_DEBUG_POSTFIX}") # Fix a "bug" in CMake, which does not include all transitive link libraries for a given target LIST(FIND PLUGIN_LINK_LIBRARIES org_blueberry_test _is_unittest_plugin) IF(NOT _is_unittest_plugin EQUAL -1) TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized CppUnit debug CppUnitd) ENDIF() + IF(MINGW) + TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ssp) # add stack smash protection lib + ENDIF() + #SET_TARGET_PROPERTIES(${PLUGIN_TARGET} PROPERTIES PREFIX lib IMPORT_PREFIX lib) SET_TARGET_PROPERTIES(${PLUGIN_TARGET} PROPERTIES PREFIX lib) #------------------------------------------------------------# #------------------ Installer support -----------------------# SET(install_directories "") IF(NOT MACOSX_BUNDLE_NAMES) SET(install_directories bin) ELSE(NOT MACOSX_BUNDLE_NAMES) FOREACH(bundle_name ${MACOSX_BUNDLE_NAMES}) LIST(APPEND install_directories ${bundle_name}.app/Contents/MacOS) ENDFOREACH(bundle_name) ENDIF(NOT MACOSX_BUNDLE_NAMES) FOREACH(install_subdir ${install_directories}) FILE(RELATIVE_PATH _toplevel_dir "${PLUGINS_SOURCE_BASE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") STRING(REGEX REPLACE ".*/(.+)/?$" "\\1" _toplevel_output_dir ${PLUGINS_OUTPUT_BASE_DIR}) MACRO_INSTALL_PLUGIN("${PLUGINS_OUTPUT_BASE_DIR}/${_toplevel_dir}" TARGETS ${PLUGIN_TARGET} DESTINATION "${install_subdir}/${_toplevel_output_dir}") ENDFOREACH() ENDMACRO(MACRO_CREATE_PLUGIN) # Macro to set specific Qt options, calls CREATE_PLUGIN at the end MACRO(MACRO_CREATE_QT_PLUGIN) IF(QT4_FOUND) INCLUDE(${QT_USE_FILE}) MACRO_CREATE_PLUGIN() TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ${QT_LIBRARIES}) ENDIF(QT4_FOUND) ENDMACRO(MACRO_CREATE_QT_PLUGIN) diff --git a/CMake/MITKDashboardDriverScript.cmake b/CMake/MITKDashboardDriverScript.cmake index 9b4c2d0790..790cc4aaf3 100644 --- a/CMake/MITKDashboardDriverScript.cmake +++ b/CMake/MITKDashboardDriverScript.cmake @@ -1,384 +1,392 @@ # # Included from a dashboard script, this cmake file will drive the configure and build # steps of MITK # #----------------------------------------------------------------------------- # The following variable are expected to be define in the top-level script: set(expected_variables CTEST_NOTES_FILES CTEST_SITE CTEST_DASHBOARD_ROOT CTEST_CMAKE_COMMAND CTEST_CMAKE_GENERATOR WITH_MEMCHECK WITH_COVERAGE WITH_DOCUMENTATION CTEST_BUILD_CONFIGURATION CTEST_TEST_TIMEOUT CTEST_BUILD_FLAGS TEST_TO_EXCLUDE_REGEX CTEST_SOURCE_DIRECTORY CTEST_BINARY_DIRECTORY CTEST_BUILD_NAME SCRIPT_MODE CTEST_COVERAGE_COMMAND CTEST_MEMORYCHECK_COMMAND CTEST_GIT_COMMAND QT_QMAKE_EXECUTABLE PROJECT_BUILD_DIR SUPERBUILD_TARGETS ) foreach(var ${expected_variables}) if(NOT DEFINED ${var}) message(FATAL_ERROR "Variable ${var} should be defined in top-level script !") endif() endforeach() if (NOT DEFINED GIT_BRANCH OR GIT_BRANCH STREQUAL "") set(GIT_BRANCH "") else() set(GIT_BRANCH "-b ${GIT_BRANCH}") endif() # Should binary directory be cleaned? set(empty_binary_directory FALSE) # Attempt to build and test also if 'ctest_update' returned an error set(initial_force_build FALSE) # Set model options set(model "") if (SCRIPT_MODE STREQUAL "experimental") set(empty_binary_directory FALSE) set(initial_force_build TRUE) set(model Experimental) elseif (SCRIPT_MODE STREQUAL "continuous") set(empty_binary_directory FALSE) set(initial_force_build FALSE) set(model Continuous) elseif (SCRIPT_MODE STREQUAL "nightly") set(empty_binary_directory TRUE) set(initial_force_build TRUE) set(model Nightly) else() message(FATAL_ERROR "Unknown script mode: '${SCRIPT_MODE}'. Script mode should be either 'experimental', 'continuous' or 'nightly'") endif() #message("script_mode:${SCRIPT_MODE}") #message("model:${model}") #message("empty_binary_directory:${empty_binary_directory}") #message("force_build:${initial_force_build}") if(empty_binary_directory) message("Directory ${CTEST_BINARY_DIRECTORY} cleaned !") ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) endif() if(NOT DEFINED CTEST_CHECKOUT_DIR) set(CTEST_CHECKOUT_DIR ${CTEST_SOURCE_DIRECTORY}) endif() if(NOT EXISTS "${CTEST_CHECKOUT_DIR}") set(CTEST_CHECKOUT_COMMAND "\"${CTEST_GIT_COMMAND}\" clone ${GIT_BRANCH} ${GIT_REPOSITORY} \"${CTEST_CHECKOUT_DIR}\"") endif() set(CTEST_UPDATE_TYPE "git") set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") #---------------------------------------------------------------------- # Utility macros #---------------------------------------------------------------------- function(func_build_target target build_dir) set(CTEST_BUILD_TARGET ${target}) ctest_build(BUILD "${build_dir}" APPEND RETURN_VALUE res NUMBER_ERRORS num_errors NUMBER_WARNINGS num_warnings) ctest_submit(PARTS Build) if(num_errors) math(EXPR build_errors "${build_errors} + ${num_errors}") set(build_errors ${build_errors} PARENT_SCOPE) endif() if(num_warnings) math(EXPR build_warnings "${build_warnings} + ${num_warnings}") set(build_warnings ${build_warnings} PARENT_SCOPE) endif() endfunction() function(func_test label build_dir) ctest_test(BUILD "${build_dir}" INCLUDE_LABEL ${label} PARALLEL_LEVEL 8 EXCLUDE ${TEST_TO_EXCLUDE_REGEX} RETURN_VALUE res ) ctest_submit(PARTS Test) if(res) math(EXPR test_errors "${test_errors} + 1") set(test_errors ${test_errors} PARENT_SCOPE) endif() if(ARG3) set(WITH_COVERAGE ${ARG3}) endif() if(ARG4) set(WITH_MEMCHECK ${ARG4}) endif() if(WITH_COVERAGE AND CTEST_COVERAGE_COMMAND) message("----------- [ Coverage ${label} ] -----------") ctest_coverage(BUILD "${build_dir}" LABELS ${label}) ctest_submit(PARTS Coverage) endif () #if(WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND) # ctest_memcheck(BUILD "${build_dir}" INCLUDE_LABEL ${label}) # ctest_submit(PARTS MemCheck) #endif () endfunction() #--------------------------------------------------------------------- # run_ctest macro #--------------------------------------------------------------------- MACRO(run_ctest) set(build_warnings 0) set(build_errors 0) set(test_errors 0) ctest_start(${model}) ctest_update(SOURCE "${CTEST_CHECKOUT_DIR}" RETURN_VALUE res) if(res LESS 0) # update error math(EXPR build_errors "${build_errors} + 1") endif() set(force_build ${initial_force_build}) if(COMMAND MITK_OVERRIDE_FORCE_BUILD) MITK_OVERRIDE_FORCE_BUILD(force_build) endif() # force a build if this is the first run and the build dir is empty if(NOT EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt") message("First time build - Initialize CMakeCache.txt") set(res 1) # Write initial cache. file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " CTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS} BUILD_TESTING:BOOL=TRUE MITK_CTEST_SCRIPT_MODE:BOOL=TRUE CMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} QT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} WITH_COVERAGE:BOOL=${WITH_COVERAGE} ${INITIAL_CMAKECACHE_OPTIONS} ") endif() if(res GREATER 0 OR force_build) + if(CTEST_PROJECT_NAME_SUPERBUILD) + set(ctest_project_name_orig ${CTEST_PROJECT_NAME}) + set(CTEST_PROJECT_NAME ${CTEST_PROJECT_NAME_SUPERBUILD}) + endif() + message("----------- [ Configure SuperBuild ] -----------") set_property(GLOBAL PROPERTY SubProject SuperBuild) set_property(GLOBAL PROPERTY Label SuperBuild) ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "-DCTEST_USE_LAUNCHERS=${CTEST_USE_LAUNCHERS}" RETURN_VALUE res ) if(res) math(EXPR build_errors "${build_errors} + 1") endif() # Project.xml is generated during the superbuild configure step ctest_submit(FILES "${CTEST_BINARY_DIRECTORY}/Project.xml") ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") ctest_submit(PARTS Configure) # submit the update results *after* the submitting the Configure info, # otherwise CDash is somehow confused and cannot add the update info # to the superbuild project ctest_submit(PARTS Update) # To get CTEST_PROJECT_SUBPROJECTS and CTEST_PROJECT_EXTERNALS definition include("${CTEST_BINARY_DIRECTORY}/CTestConfigSubProject.cmake") # Build top level (either all or the supplied targets at # superbuild level if(SUPERBUILD_TARGETS) foreach(superbuild_target ${SUPERBUILD_TARGETS}) message("----------- [ Build ${superbuild_target} - SuperBuild ] -----------") func_build_target(${superbuild_target} "${CTEST_BINARY_DIRECTORY}") # runs only tests that have a LABELS property matching "SuperBuild" func_test("SuperBuild" "${CTEST_BINARY_DIRECTORY}") endforeach() # HACK Unfortunately ctest_coverage ignores the build argument, back-up the original dirs file(READ "${CTEST_BINARY_DIRECTORY}/CMakeFiles/TargetDirectories.txt" old_coverage_dirs) # explicitly build requested external projects as subprojects foreach(external_project_with_build_dir ${CTEST_PROJECT_EXTERNALS}) string(REPLACE "^^" ";" external_project_with_build_dir_list "${external_project_with_build_dir}") list(GET external_project_with_build_dir_list 0 external_project) list(GET external_project_with_build_dir_list 1 external_project_build_dir) set_property(GLOBAL PROPERTY SubProject ${external_project}) set_property(GLOBAL PROPERTY Label ${external_project}) message("----------- [ Build ${external_project} ] -----------") # Build target func_build_target(${external_project} "${CTEST_BINARY_DIRECTORY}") # HACK Unfortunately ctest_coverage ignores the build argument, try to force it... file(READ "${CTEST_BINARY_DIRECTORY}/${external_project_build_dir}/CMakeFiles/TargetDirectories.txt" mitk_build_coverage_dirs) file(APPEND "${CTEST_BINARY_DIRECTORY}/CMakeFiles/TargetDirectories.txt" "${mitk_build_coverage_dirs}") message("----------- [ Test ${external_project} ] -----------") # runs only tests that have a LABELS property matching "${external_project}" func_test(${external_project} "${CTEST_BINARY_DIRECTORY}/${external_project_build_dir}") # restore old coverage dirs file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeFiles/TargetDirectories.txt" "${old_coverage_dirs}") endforeach() # switch back to SuperBuild label set_property(GLOBAL PROPERTY SubProject SuperBuild) set_property(GLOBAL PROPERTY Label SuperBuild) message("----------- [ Finish SuperBuild ] -----------") else() message("----------- [ Build SuperBuild ] -----------") endif() # build everything at superbuild level which has not yet been built func_build_target("" "${CTEST_BINARY_DIRECTORY}") # runs only tests that have a LABELS property matching "SuperBuild" #func_test("SuperBuild" "${CTEST_BINARY_DIRECTORY}") set(build_dir "${CTEST_BINARY_DIRECTORY}/${PROJECT_BUILD_DIR}") + if(CTEST_PROJECT_NAME_SUPERBUILD) + set(CTEST_PROJECT_NAME ${ctest_project_name_orig}) + endif() message("----------- [ Configure ${build_dir} ] -----------") # Configure target ctest_configure(BUILD "${build_dir}" OPTIONS "-DCTEST_USE_LAUNCHERS=${CTEST_USE_LAUNCHERS}" RETURN_VALUE res ) ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") ctest_submit(PARTS Configure) if(res) math(EXPR build_errors "${build_errors} + 1") endif() foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) set_property(GLOBAL PROPERTY SubProject ${subproject}) set_property(GLOBAL PROPERTY Label ${subproject}) message("----------- [ Build ${subproject} ] -----------") # Build target func_build_target(${subproject} "${build_dir}") endforeach() # Build the rest of the project set_property(GLOBAL PROPERTY SubProject SuperBuild) set_property(GLOBAL PROPERTY Label SuperBuild) message("----------- [ Build All ] -----------") func_build_target("" "${build_dir}") # HACK Unfortunately ctest_coverage ignores the build argument, try to force it... file(READ ${build_dir}/CMakeFiles/TargetDirectories.txt mitk_build_coverage_dirs) file(APPEND "${CTEST_BINARY_DIRECTORY}/CMakeFiles/TargetDirectories.txt" "${mitk_build_coverage_dirs}") foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) set_property(GLOBAL PROPERTY SubProject ${subproject}) set_property(GLOBAL PROPERTY Label ${subproject}) message("----------- [ Test ${subproject} ] -----------") # runs only tests that have a LABELS property matching "${subproject}" func_test(${subproject} "${build_dir}") endforeach() if (WITH_DOCUMENTATION) message("----------- [ Build Documentation ] -----------") set(CTEST_USE_LAUNCHERS 0) # Build Documentation target set_property(GLOBAL PROPERTY SubProject Documentation) set_property(GLOBAL PROPERTY Label Documentation) func_build_target("doc" "${build_dir}") set(CTEST_USE_LAUNCHERS 1) endif() set_property(GLOBAL PROPERTY SubProject SuperBuild) set_property(GLOBAL PROPERTY Label SuperBuild) # Global coverage ... if (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND) message("----------- [ Global coverage ] -----------") ctest_coverage(BUILD "${build_dir}" APPEND) ctest_submit(PARTS Coverage) endif () # Global dynamic analysis ... if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND) message("----------- [ Global memcheck ] -----------") ctest_memcheck(BUILD "${build_dir}") ctest_submit(PARTS MemCheck) endif () # Note should be at the end ctest_submit(PARTS Notes) # Send status to the "CDash Web Admin" if(NOT MITK_NO_CDASH_WEBADMIN) set(cdash_admin_url "http://mbits/cdashadmin-web/index.php?pw=4da12ca9c06d46d3171d7f73974c900f") string(REGEX REPLACE ".*\\?project=(.*)&?" "\\1" _ctest_project "${CTEST_DROP_LOCATION}") file(DOWNLOAD "${cdash_admin_url}&action=submit&name=${CTEST_BUILD_NAME}&hasTestErrors=${test_errors}&hasBuildErrors=${build_errors}&hasBuildWarnings=${build_warnings}&ctestDropSite=${CTEST_DROP_SITE}&ctestProject=${_ctest_project}" "${CTEST_BINARY_DIRECTORY}/cdashadmin.txt" STATUS status ) list(GET status 0 error_code) list(GET status 1 error_msg) if(error_code) message(FATAL_ERROR "error: Failed to communicate with cdashadmin-web - ${error_msg}") endif() endif() endif() # Clear the CTEST_CHECKOUT_COMMAND variable to prevent continuous clients # to try to checkout again set(CTEST_CHECKOUT_COMMAND "") endmacro() if(SCRIPT_MODE STREQUAL "continuous") while(1) run_ctest() # Loop no faster than once every 5 minutes message("Wait for 5 minutes ...") ctest_sleep(300) endwhile() else() run_ctest() endif() diff --git a/CMake/mitkMacroCreateModule.cmake b/CMake/mitkMacroCreateModule.cmake index cb67f60561..d88fa16266 100644 --- a/CMake/mitkMacroCreateModule.cmake +++ b/CMake/mitkMacroCreateModule.cmake @@ -1,190 +1,197 @@ ################################################################## # # MITK_CREATE_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) + + IF(MINGW) + TARGET_LINK_LIBRARIES(${MODULE_PROVIDES} ssp) # add stack smash protection lib + ENDIF() 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(MINGW) + TARGET_LINK_LIBRARIES(${MODULE_PROVIDES} ssp) # add stack smash protection lib + ENDIF() 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/mitkMacroInstall.cmake b/CMake/mitkMacroInstall.cmake index 931e67854e..08710a902c 100644 --- a/CMake/mitkMacroInstall.cmake +++ b/CMake/mitkMacroInstall.cmake @@ -1,137 +1,137 @@ # # MITK specific install macro # # On Mac everything is installed for each bundle listed in MACOSX_BUNDLE_NAMES # by replacing the DESTINATION parameter. Everything else is passed to the CMake INSTALL command # # Usage: MITK_INSTALL( ) # MACRO(MITK_INSTALL) SET(ARGS ${ARGN}) SET(install_directories "") LIST(FIND ARGS DESTINATION _destination_index) # SET(_install_DESTINATION "") IF(_destination_index GREATER -1) MESSAGE(SEND_ERROR "MITK_INSTALL macro must not be called with a DESTINATION parameter.") ### This code was a try to replace a given DESTINATION #MATH(EXPR _destination_index ${_destination_index} + 1) #LIST(GET ARGS ${_destination_index} _install_DESTINATION) #STRING(REGEX REPLACE ^bin "" _install_DESTINATION ${_install_DESTINATION}) ELSE() IF(NOT MACOSX_BUNDLE_NAMES) INSTALL(${ARGS} DESTINATION bin) ELSE() FOREACH(bundle_name ${MACOSX_BUNDLE_NAMES}) INSTALL(${ARGS} DESTINATION ${bundle_name}.app/Contents/MacOS/${_install_DESTINATION}) ENDFOREACH() ENDIF() ENDIF() ENDMACRO() # Fix _target_location # This is used in several install macros MACRO(_fixup_target) INSTALL(CODE " MACRO(gp_item_default_embedded_path_override item default_embedded_path_var) GET_FILENAME_COMPONENT(_item_name \"\${item}\" NAME) GET_FILENAME_COMPONENT(_item_path \"\${item}\" PATH) IF(_item_name MATCHES \"liborg\") IF(APPLE) SET(full_path \"full_path-NOTFOUND\") MESSAGE(\"override: \${item}\") FILE (GLOB_RECURSE full_path \${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}/\${_item_name} ) MESSAGE(\"find file: \${full_path}\") GET_FILENAME_COMPONENT(_item_path \"\${full_path}\" PATH) STRING(REPLACE \${CMAKE_INSTALL_PREFIX} @executable_path/../../../ \${default_embedded_path_var} \"\${_item_path}\" ) MESSAGE(\"override result: \${\${default_embedded_path_var}}\") ELSE() SET(\${default_embedded_path_var} \"\${_item_path}\") ENDIF() ENDIF() #IF(_item_name MATCHES \"^liborg\") # IF(APPLE) # MESSAGE(\"override: \${item}\") # STRING(REPLACE # ${CMAKE_INSTALL_PREFIX} # @loader_path/../ \${default_embedded_path_var} \"\${_item_path}\" ) # ELSE(APPLE) # SET(\${default_embedded_path_var} \"\${_item_path}\") # ENDIF(APPLE) #ENDIF() ENDMACRO(gp_item_default_embedded_path_override) MACRO(gp_resolved_file_type_override file type) IF(NOT APPLE) GET_FILENAME_COMPONENT(_file_path \"\${file}\" PATH) GET_FILENAME_COMPONENT(_file_name \"\${file}\" NAME) IF(_file_path MATCHES \"^\${CMAKE_INSTALL_PREFIX}\") SET(\${type} \"local\") # On linux, rpaths are removed from the plugins # if installing more than on application. This override # should prevent this. IF(_file_name MATCHES \"^liborg\") SET(\${type} \"system\") ENDIF() ENDIF() IF(_file_name MATCHES gdiplus) SET(\${type} \"system\") ENDIF(_file_name MATCHES gdiplus) ENDIF() ENDMACRO(gp_resolved_file_type_override) SET(_rpath_relative ${MITK_INSTALL_RPATH_RELATIVE}) IF(_rpath_relative AND NOT APPLE) IF(UNIX OR MINGW) MACRO(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) IF(\${item} MATCHES \"blueberry_osgi\") SET(\${resolved_item_var} \"\${exepath}/BlueBerry/org.blueberry.osgi/bin/\${item}\") SET(\${resolved_var} 1) ENDIF() ENDMACRO() ENDIF() ENDIF() IF(\"${_install_GLOB_PLUGINS}\" STREQUAL \"TRUE\") file(GLOB_RECURSE GLOBBED_BLUEBERRY_PLUGINS # glob for all blueberry bundles of this application \"\${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}/liborg*${CMAKE_SHARED_LIBRARY_SUFFIX}\" ) file(GLOB_RECURSE GLOBBED_QT_PLUGINS # glob for Qt plugins \"\${CMAKE_INSTALL_PREFIX}/${${_target_location}_qt_plugins_install_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\" ) ELSE() file(GLOB_RECURSE GLOBBED_QT_PLUGINS # glob for Qt plugins \"\${CMAKE_INSTALL_PREFIX}/${${_target_location}_qt_plugins_install_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") ENDIF() # use custom version of BundleUtilities - message(\"globbed plugins: \${PLUGINS}\") + message(\"globbed plugins: \${GLOBBED_QT_PLUGINS} \${GLOBBED_BLUEBERRY_PLUGINS}\") SET(PLUGIN_DIRS ${DIRS}) - SET(PLUGINS ${_install_PLUGINS}) + SET(PLUGINS ${_install_PLUGINS} \${GLOBBED_QT_PLUGINS} \${GLOBBED_BLUEBERRY_PLUGINS}) if (PLUGINS) list(REMOVE_DUPLICATES PLUGINS) endif (PLUGINS) foreach(_plugin \${GLOBBED_BLUEBERRY_PLUGINS}) get_filename_component(_pluginpath \${_plugin} PATH) list(APPEND PLUGIN_DIRS \${_pluginpath}) list(REMOVE_DUPLICATES PLUGIN_DIRS) endforeach(_plugin) list(APPEND DIRS \${PLUGIN_DIRS}) # use custom version of BundleUtilities SET(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) include(BundleUtilities) list(REMOVE_DUPLICATES PLUGIN_DIRS) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${_target_location}\" \"\${PLUGINS}\" \"\${PLUGIN_DIRS}\") ") ENDMACRO() diff --git a/CMake/mitkMacroInstallTargets.cmake b/CMake/mitkMacroInstallTargets.cmake index cdf652baf3..ba4c9e04b5 100644 --- a/CMake/mitkMacroInstallTargets.cmake +++ b/CMake/mitkMacroInstallTargets.cmake @@ -1,122 +1,122 @@ # # MITK specific cross plattform install macro # # Usage: MITK_INSTALL_TARGETS(target1 [target2] ....) # MACRO(MITK_INSTALL_TARGETS) 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_DIR}/bin/${intermediate_dir} + ${MITK_BINARY_DIR}/bin/${intermediate_dir} ${_install_LIBRARY_DIRS} ) 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}) GET_TARGET_PROPERTY(_is_bundle ${_target} MACOSX_BUNDLE) SET(_qt_plugins_install_dirs "") SET(_qt_conf_install_dirs "") SET(_target_locations "") IF(APPLE) IF(_is_bundle) SET(_target_locations ${_target}.app) SET(${_target_locations}_qt_plugins_install_dir ${_target}.app/Contents/MacOS) SET(_bundle_dest_dir ${_target}.app/Contents/MacOS) SET(_qt_plugins_for_current_bundle ${_target}.app/Contents/MacOS) SET(_qt_conf_install_dirs ${_target}.app/Contents/Resources) INSTALL(TARGETS ${_target} BUNDLE DESTINATION . ) ELSE() IF(NOT MACOSX_BUNDLE_NAMES) SET(_qt_conf_install_dirs bin) SET(_target_locations bin/${_target}) SET(${_target_locations}_qt_plugins_install_dir bin) INSTALL(TARGETS ${_target} RUNTIME 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}) LIST(APPEND _target_locations ${_current_target_location}) SET(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) MESSAGE( " SET(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) ") INSTALL(TARGETS ${_target} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/) ENDFOREACH() ENDIF() ENDIF() ELSE() SET(_target_locations bin/${_target}${CMAKE_EXECUTABLE_SUFFIX}) SET(${_target_locations}_qt_plugins_install_dir bin) SET(_qt_conf_install_dirs bin) INSTALL(TARGETS ${_target} RUNTIME 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() 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() diff --git a/CMakeExternals/ITK.cmake b/CMakeExternals/ITK.cmake index 94cb65e476..aad3234068 100644 --- a/CMakeExternals/ITK.cmake +++ b/CMakeExternals/ITK.cmake @@ -1,35 +1,44 @@ #----------------------------------------------------------------------------- # ITK #----------------------------------------------------------------------------- # Sanity checks IF(DEFINED ITK_DIR AND NOT EXISTS ${ITK_DIR}) MESSAGE(FATAL_ERROR "ITK_DIR variable is defined but corresponds to non-existing directory") ENDIF() SET(proj ITK) SET(proj_DEPENDENCIES GDCM) SET(ITK_DEPENDS ${proj}) IF(NOT DEFINED ITK_DIR) + + SET(additional_cmake_args ) + IF(MINGW) + SET(additional_cmake_args + -DCMAKE_USE_WIN32_THREADS:BOOL=ON + -DCMAKE_USE_PTHREADS:BOOL=OFF) + ENDIF() + ExternalProject_Add(${proj} URL http://mitk.org/download/thirdparty/InsightToolkit-3.20.0.tar.gz BINARY_DIR ${proj}-build INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} + ${additional_cmake_args} -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DITK_USE_SYSTEM_GDCM:BOOL=ON -DGDCM_DIR:PATH=${GDCM_DIR} DEPENDS ${proj_DEPENDENCIES} ) SET(ITK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) ELSE() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") ENDIF() diff --git a/CMakeExternals/VTK.cmake b/CMakeExternals/VTK.cmake index c451c5083b..1ab2f3cf2b 100644 --- a/CMakeExternals/VTK.cmake +++ b/CMakeExternals/VTK.cmake @@ -1,45 +1,56 @@ #----------------------------------------------------------------------------- # VTK #----------------------------------------------------------------------------- IF(WIN32) OPTION(VTK_USE_SYSTEM_FREETYPE OFF) ELSE(WIN32) OPTION(VTK_USE_SYSTEM_FREETYPE ON) ENDIF(WIN32) # Sanity checks IF(DEFINED VTK_DIR AND NOT EXISTS ${VTK_DIR}) MESSAGE(FATAL_ERROR "VTK_DIR variable is defined but corresponds to non-existing directory") ENDIF() SET(proj VTK) SET(proj_DEPENDENCIES ) SET(VTK_DEPENDS ${proj}) IF(NOT DEFINED VTK_DIR) + + SET(additional_cmake_args ) + IF(MINGW) + SET(additional_cmake_args + -DCMAKE_USE_WIN32_THREADS:BOOL=ON + -DCMAKE_USE_PTHREADS:BOOL=OFF + -DVTK_USE_VIDEO4WINDOWS:BOOL=OFF # no header files provided by MinGW + ) + ENDIF() + ExternalProject_Add(${proj} URL http://mitk.org/download/thirdparty/vtk-5.6.1.tar.gz BINARY_DIR ${proj}-build INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} + ${additional_cmake_args} -DVTK_WRAP_TCL:BOOL=OFF -DVTK_WRAP_PYTHON:BOOL=OFF -DVTK_WRAP_JAVA:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON -DVTK_USE_PARALLEL:BOOL=ON -DVTK_USE_CHARTS:BOOL=OFF -DVTK_USE_GEOVIS:BOOL=OFF -DVTK_USE_SYSTEM_FREETYPE:BOOL=${VTK_USE_SYSTEM_FREETYPE} ${vtk_QT_ARGS} DEPENDS ${proj_DEPENDENCIES} ) SET(VTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) ELSE() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") ENDIF() diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b3d893e6c..3f62bbf2bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,477 +1,485 @@ cmake_minimum_required(VERSION 2.8.2) #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) if(MITK_USE_SUPERBUILD) project(MITK-superbuild) set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR}) else() project(MITK) endif() #----------------------------------------------------------------------------- # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details #----------------------------------------------------------------------------- set(project_policies CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. CMP0002 # NEW: Logical target names must be globally unique. CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths. CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace. CMP0005 # NEW: Preprocessor definition values are now escaped automatically. CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. CMP0007 # NEW: List command no longer ignores empty elements. CMP0008 # NEW: Libraries linked by full-path must have a valid library file name. CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default. CMP0010 # NEW: Bad variable reference syntax is an error. CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP. CMP0012 # NEW: if() recognizes numbers and boolean constants. CMP0013 # NEW: Duplicate binary directories are not allowed. CMP0014 # NEW: Input directories must have CMakeLists.txt ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) - message(FATAL_ERROR "MITK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}]") + message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") + file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") endif() if(MITK_USE_SUPERBUILD) set(output_dir ${MITK_BINARY_DIR}/bin) if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_BINARY_DIR}/MITK-build/bin) endif() else() if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) SET(output_dir ${MITK_BINARY_DIR}/bin) else() SET(output_dir ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) endif() endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) # some targets in Utilities also depend on Qt. Use this option # to decide if they should be build option(MITK_USE_QT "Use Trolltech's Qt library" ON) if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available find_package(Qt4 4.6.0 REQUIRED) endif() option(MITK_INSTALL_RPATH_RELATIVE "Use relative rpath entries for installation packages" OFF) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) option(MITK_BUILD_TUTORIAL "Build the MITK tutorial" ON) option(MITK_USE_Boost "Use the Boost C++ library" OFF) option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_CTK "EXEPERIMENTAL, superbuild only: Use CTK in MITK" OFF) option(MITK_USE_DCMTK "EXEPERIMENTAL, superbuild only: Use DCMTK in MITK" OFF) option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) mark_as_advanced(MITK_INSTALL_RPATH_RELATIVE MITK_BUILD_ALL_PLUGINS MITK_USE_CTK MITK_USE_DCMTK ) #----------------------------------------------------------------------------- # Additional CXX/C Flags #----------------------------------------------------------------------------- set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags") mark_as_advanced(ADDITIONAL_C_FLAGS) set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") mark_as_advanced(ADDITIONAL_CXX_FLAGS) #----------------------------------------------------------------------------- # Project.xml #----------------------------------------------------------------------------- # A list of topologically ordered targets set(CTEST_PROJECT_SUBPROJECTS) if(MITK_USE_BLUEBERRY) list(APPEND CTEST_PROJECT_SUBPROJECTS BlueBerry) endif() list(APPEND CTEST_PROJECT_SUBPROJECTS MITK-Core MITK-CoreUI MITK-IGT MITK-ToF MITK-DTI MITK-Registration MITK-Modules # all modules not contained in a specific subproject MITK-Plugins # all plugins not contained in a specific subproject ) # Configure CTestConfigSubProject.cmake that could be used by CTest scripts configure_file(${MITK_SOURCE_DIR}/CTestConfigSubProject.cmake.in ${MITK_BINARY_DIR}/CTestConfigSubProject.cmake) # Generate Project.xml file expected by the CTest driver script mitkFunctionGenerateProjectXml(${MITK_BINARY_DIR} ${PROJECT_NAME} "${CTEST_PROJECT_SUBPROJECTS}" ${MITK_USE_SUPERBUILD}) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkFunctionCheckCompilerFlags) include(mitkFunctionGetGccVersion) include(MacroParseArguments) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkFunctionOrganizeSources) include(mitkFunctionGetVersion) include(mitkFunctionCreateWindowsBatchScript) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(ITK REQUIRED) find_package(VTK REQUIRED) #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and ExtApp option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON) mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW) # TODO: check if necessary option(USE_ITKZLIB "Use the ITK zlib for pic compression." ON) mark_as_advanced(USE_ITKZLIB) #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) +#----------------------------------------------------------------------------- +# Installation preparation +# +# These should be set before any MITK install macros are used +#----------------------------------------------------------------------------- + +if(MITK_INSTALL_RPATH_RELATIVE) + set(CMAKE_INSTALL_RPATH ".") +else() + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/bin") +endif() + +# on Mac OSX all BlueBerry plugins get copied into every +# application bundle (.app directory) specified here +if(APPLE) + if(MITK_BUILD_org.mitk.gui.qt.extapplication) + set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} ExtApp) + endif() + if(MITK_BUILD_org.mitk.gui.qt.application) + set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} CoreApp) + endif() +endif(APPLE) + #----------------------------------------------------------------------------- # Set symbol visibility Flags #----------------------------------------------------------------------------- # MinGW does not export all symbols automatically, so no need to set flags if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) set(VISIBILITY_CXX_FLAGS ) #"-fvisibility=hidden -fvisibility-inlines-hidden") endif() #----------------------------------------------------------------------------- # Set coverage Flags #----------------------------------------------------------------------------- if(WITH_COVERAGE) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") set(COVERAGE_CXX_FLAGS ${coverage_flags}) set(COVERAGE_C_FLAGS ${coverage_flags}) endif() endif() #----------------------------------------------------------------------------- # MITK C/CXX Flags #----------------------------------------------------------------------------- set(MITK_C_FLAGS "${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}") set(MITK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}") if(CMAKE_COMPILER_IS_GNUCXX) set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2") mitkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag. # Doing so should allow to build package made for distribution using older linux distro. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0")) mitkFunctionCheckCompilerFlags("-fstack-protector-all" cflags) endif() if(MINGW) # suppress warnings about auto imported symbols set(MITK_CXX_FLAGS "-Wl,--enable-auto-import ${MITK_CXX_FLAGS}") # we need to define a Windows version set(MITK_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${MITK_CXX_FLAGS}") endif() set(MITK_C_FLAGS "${cflags} ${MITK_C_FLAGS}") #set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${MITK_CXX_FLAGS}") set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wstrict-null-sentinel ${MITK_CXX_FLAGS}") endif() #----------------------------------------------------------------------------- # MITK Modules #----------------------------------------------------------------------------- set(MITK_MODULES_CONF_DIR ${MITK_BINARY_DIR}/modulesConf CACHE INTERNAL "Modules Conf") set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) option(MITK_ENABLE_GUI_TESTING OFF "Enable the MITK GUI tests") # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @ONLY ) # Configuration for the CMake-generated test driver set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " try {") set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " } catch( std::exception & excp ) { fprintf(stderr,\"%s\\n\",excp.what()); return EXIT_FAILURE; } catch( ... ) { printf(\"Exception caught in the test driver\\n\"); return EXIT_FAILURE; } ") set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output") if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR}) endif() endif() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) #----------------------------------------------------------------------------- # MITK_SUPERBUILD_BINARY_DIR #----------------------------------------------------------------------------- # If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild. # In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR) set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # Compile Utilities and set-up MITK variables #----------------------------------------------------------------------------- add_subdirectory(Utilities) include(mitkSetupVariables) if(MITK_USE_BLUEBERRY) include(mitkSetupBlueBerry) endif() #----------------------------------------------------------------------------- # Set C/CXX Flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}" CACHE STRING "CMake CXX Flags" FORCE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}" CACHE STRING "CMake C Flags" FORCE) if(MITK_USE_QT) add_definitions(-DQWT_DLL) endif() #----------------------------------------------------------------------------- # Add custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject}) add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Python Wrapping #----------------------------------------------------------------------------- set(MITK_WRAPPING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Wrapping) set(MITK_WRAPPING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Wrapping) option(MITK_USE_PYTHON "Build cswig Python wrapper support (requires CableSwig)." OFF) if(MITK_USE_PYTHON) add_subdirectory(Wrapping) endif() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- link_directories(${MITK_LINK_DIRECTORIES}) add_subdirectory(Core) add_subdirectory(CoreUI) add_subdirectory(Modules) add_subdirectory(Applications) #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- add_subdirectory(Documentation) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- -if(MITK_INSTALL_RPATH_RELATIVE) - set(CMAKE_INSTALL_RPATH ".") -else() - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/bin") -endif() - -# on Mac OSX all BlueBerry plugins get copied into every -# application bundle (.app directory) specified here -if(APPLE) - if(MITK_BUILD_org.mitk.gui.qt.extapplication) - set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} ExtApp) - endif() - if(MITK_BUILD_org.mitk.gui.qt.application) - set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} CoreApp) - endif() -endif(APPLE) # set MITK cpack variables include(mitkSetupCPack) if(MITK_BUILD_org.mitk.gui.qt.application) list(APPEND CPACK_CREATE_DESKTOP_LINKS "CoreApp") endif() if(MITK_BUILD_org.mitk.gui.qt.extapplication) list(APPEND CPACK_CREATE_DESKTOP_LINKS "ExtApp") endif() configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) if(MITK_USE_BLUEBERRY) set(enabled_plugins ${BLUEBERRY_ENABLED_PLUGINS} ${MITK_CORE_ENABLED_PLUGINS} ${MITK_MODULES_ENABLED_PLUGINS} ) # This is for installation support of external projects depending on # MITK plugins. The export file should not be used for linking to MITK # libraries without using LINK_DIRECTORIES, since the exports are incomplete # yet(depending libraries are not exported). foreach(plugin ${enabled_plugins}) string(REPLACE "." "_" plugin_target ${plugin}) export(TARGETS ${plugin_target} APPEND FILE ${MITK_EXPORTS_FILE}) endforeach() endif() configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(VECMATH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/vecmath) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 876b7a2913..2abf872117 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -1,8 +1,9 @@ -set(CTEST_PROJECT_NAME "MITK-superbuild") +set(CTEST_PROJECT_NAME_SUPERBUILD "MITK-superbuild") +set(CTEST_PROJECT_NAME "MITK") set(CTEST_NIGHTLY_START_TIME "23:00:00 EDT") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "cdash.mitk.org") set(CTEST_DROP_LOCATION "/submit.php?project=MITK") set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp index 311ac9117b..fa1b178715 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp @@ -1,268 +1,281 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkMITKIGTTrackingToolboxView.h" #include "QmitkStdMultiWidget.h" // Qt #include #include // MITK #include #include #include const std::string QmitkMITKIGTTrackingToolboxView::VIEW_ID = "org.mitk.views.mitkigttrackingtoolbox"; QmitkMITKIGTTrackingToolboxView::QmitkMITKIGTTrackingToolboxView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) { m_TrackingTimer = new QTimer(this); m_tracking = false; m_logging = false; + m_loggedFrames = 0; } QmitkMITKIGTTrackingToolboxView::~QmitkMITKIGTTrackingToolboxView() { } void QmitkMITKIGTTrackingToolboxView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkMITKIGTTrackingToolboxViewControls; m_Controls->setupUi( parent ); //create connections connect( m_Controls->m_LoadTools, SIGNAL(clicked()), this, SLOT(OnLoadTools()) ); connect( m_Controls->m_StartTracking, SIGNAL(clicked()), this, SLOT(OnStartTracking()) ); connect( m_Controls->m_StopTracking, SIGNAL(clicked()), this, SLOT(OnStopTracking()) ); connect( m_TrackingTimer, SIGNAL(timeout()), this, SLOT(UpdateTrackingTimer())); - connect( m_Controls->m_EnableLogging, SIGNAL(clicked()), this, SLOT(OnEnableLoggingClicked())); connect( m_Controls->m_ChooseFile, SIGNAL(clicked()), this, SLOT(OnChooseFileClicked())); + connect( m_Controls->m_StartLogging, SIGNAL(clicked()), this, SLOT(StartLogging())); + connect( m_Controls->m_StopLogging, SIGNAL(clicked()), this, SLOT(StopLogging())); //initialize widgets m_Controls->m_configurationWidget->EnableAdvancedUserControl(false); m_Controls->m_TrackingToolsStatusWidget->SetShowPositions(true); m_Controls->m_TrackingToolsStatusWidget->SetTextAlignment(Qt::AlignLeft); //initialize tracking volume node TrackingVolumeNode = mitk::DataNode::New(); TrackingVolumeNode->SetName("TrackingVolume"); this->GetDataStorage()->Add(TrackingVolumeNode); //initialize buttons m_Controls->m_StopTracking->setEnabled(false); } } void QmitkMITKIGTTrackingToolboxView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkMITKIGTTrackingToolboxView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkMITKIGTTrackingToolboxView::OnLoadTools() { //read in filename QString filename = QFileDialog::getOpenFileName(NULL,tr("Open Toolfile"), "/", tr("All Files (*.*)")); //later perhaps: tr("Toolfile (*.tfl)" if (filename.isNull()) return; //initialize tool storage m_toolStorage = mitk::NavigationToolStorage::New(); //read tool storage from disk mitk::NavigationToolStorageDeserializer::Pointer myDeserializer = mitk::NavigationToolStorageDeserializer::New(GetDataStorage()); m_toolStorage = myDeserializer->Deserialize(filename.toStdString()); if (m_toolStorage.IsNull()) { MessageBox(myDeserializer->GetErrorMessage()); m_toolStorage = NULL; return; } //update label Poco::Path myPath = Poco::Path(filename.toStdString()); //use this to seperate filename from path QString toolLabel = QString("Loaded Tools: ") + QString::number(m_toolStorage->GetToolCount()) + " Tools from " + myPath.getFileName().c_str(); m_Controls->m_toolLabel->setText(toolLabel); //update tool preview m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); } void QmitkMITKIGTTrackingToolboxView::OnStartTracking() { //check if everything is ready to start tracking if (this->m_toolStorage.IsNull()) { MessageBox("Error: No Tools Loaded Yet!"); return; } else if (this->m_toolStorage->GetToolCount() == 0) { MessageBox("Error: No Way To Track Without Tools!"); return; } //build the IGT pipeline mitk::TrackingDeviceSourceConfigurator::Pointer myTrackingDeviceSourceFactory = mitk::TrackingDeviceSourceConfigurator::New(this->m_toolStorage,this->m_Controls->m_configurationWidget->GetTrackingDevice()); m_TrackingDeviceSource = myTrackingDeviceSourceFactory->CreateTrackingDeviceSource(this->m_ToolVisualizationFilter); if (m_TrackingDeviceSource.IsNull()) { MessageBox(myTrackingDeviceSourceFactory->GetErrorMessage()); return; } //initialize tracking try { m_TrackingDeviceSource->Connect(); m_TrackingDeviceSource->StartTracking(); } catch (...) { MessageBox("Error while starting the tracking device!"); return; } -m_TrackingTimer->start(100); +m_TrackingTimer->start(1000/(m_Controls->m_UpdateRate->value())); m_Controls->m_TrackingControlLabel->setText("Status: tracking"); -//start logging if logging is on -if (this->m_Controls->m_EnableLogging->isChecked()) StartLogging(); - //connect the tool visualization widget for(int i=0; iGetNumberOfOutputs(); i++) { m_Controls->m_TrackingToolsStatusWidget->AddNavigationData(m_TrackingDeviceSource->GetOutput(i)); } m_Controls->m_TrackingToolsStatusWidget->ShowStatusLabels(); //disable loading new tools this->m_Controls->m_LoadTools->setEnabled(false); //set configuration finished this->m_Controls->m_configurationWidget->ConfigurationFinished(); //show tracking volume if (m_Controls->m_ShowTrackingVolume->isChecked()) { mitk::TrackingVolume::Pointer volumeSurface = mitk::TrackingVolume::New(); volumeSurface->SetTrackingDeviceType(m_TrackingDeviceSource->GetTrackingDevice()->GetType()); TrackingVolumeNode->SetData(volumeSurface); TrackingVolumeNode->SetOpacity(0.25); mitk::Color red; red.SetRed(1); TrackingVolumeNode->SetColor(red); } m_tracking = true; m_Controls->m_StopTracking->setEnabled(true); m_Controls->m_StartTracking->setEnabled(false); } void QmitkMITKIGTTrackingToolboxView::OnStopTracking() { if (!m_tracking) return; m_TrackingTimer->stop(); m_TrackingDeviceSource->StopTracking(); m_TrackingDeviceSource->Disconnect(); this->m_Controls->m_configurationWidget->Reset(); m_Controls->m_TrackingControlLabel->setText("Status: stopped"); if (m_logging) StopLogging(); this->m_Controls->m_LoadTools->setEnabled(true); m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); TrackingVolumeNode->SetData(NULL); m_tracking = false; m_Controls->m_StopTracking->setEnabled(false); m_Controls->m_StartTracking->setEnabled(true); } void QmitkMITKIGTTrackingToolboxView::MessageBox(std::string s) { QMessageBox msgBox; msgBox.setText(s.c_str()); msgBox.exec(); } void QmitkMITKIGTTrackingToolboxView::UpdateTrackingTimer() { m_ToolVisualizationFilter->Update(); - //std::cout << "Position" << m_ToolVisualizationFilter->GetOutput(0)->GetPosition() << std::endl; mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - if (m_logging) this->m_loggingFilter->Update(); + if (m_logging) + { + this->m_loggingFilter->Update(); + m_loggedFrames = this->m_loggingFilter->GetRecordCounter(); + this->m_Controls->m_LoggedFramesLabel->setText("Logged Frames: "+QString::number(m_loggedFrames)); + //check if logging stopped automatically + if((m_loggedFrames>1)&&(!m_loggingFilter->GetRecording())) + { + m_Controls->m_LoggingLabel->setText("Logging OFF"); + m_logging = false; + } + } m_Controls->m_TrackingToolsStatusWidget->Refresh(); } -void QmitkMITKIGTTrackingToolboxView::OnEnableLoggingClicked() - { - if (this->m_tracking && this->m_Controls->m_EnableLogging->isChecked() && !this->m_logging) StartLogging(); - else if (!this->m_Controls->m_EnableLogging->isChecked() && this->m_logging) StopLogging(); - } - void QmitkMITKIGTTrackingToolboxView::OnChooseFileClicked() { QString filename = QFileDialog::getSaveFileName(NULL,tr("Choose Logging File"), "/", "*.*"); this->m_Controls->m_LoggingFileName->setText(filename); } void QmitkMITKIGTTrackingToolboxView::StartLogging() { //initialize logging filter m_loggingFilter = mitk::NavigationDataRecorder::New(); m_loggingFilter->SetRecordingMode(mitk::NavigationDataRecorder::NormalFile); if (m_Controls->m_xmlFormat->isChecked()) m_loggingFilter->SetOutputFormat(mitk::NavigationDataRecorder::xml); else if (m_Controls->m_csvFormat->isChecked()) m_loggingFilter->SetOutputFormat(mitk::NavigationDataRecorder::csv); m_loggingFilter->SetFileName(m_Controls->m_LoggingFileName->text().toStdString().c_str()); + if (m_Controls->m_LoggingLimit->isChecked()){m_loggingFilter->SetRecordCountLimit(m_Controls->m_LoggedFramesLimit->value());} //connect filter for(int i=0; iGetNumberOfOutputs(); i++){m_loggingFilter->AddNavigationData(m_ToolVisualizationFilter->GetOutput(i));} - + + //start filter m_loggingFilter->StartRecording(); + + //update labels / logging variables + this->m_Controls->m_LoggingLabel->setText("Logging ON"); + this->m_Controls->m_LoggedFramesLabel->setText("Logged Frames: 0"); + m_loggedFrames = 0; m_logging = true; } void QmitkMITKIGTTrackingToolboxView::StopLogging() { + //update label + this->m_Controls->m_LoggingLabel->setText("Logging OFF"); + m_loggingFilter->StopRecording(); m_logging = false; } diff --git a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h index 7deef71c3e..cb1314636c 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h +++ b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h @@ -1,111 +1,113 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QmitkMITKIGTTrackingToolboxView_h #define QmitkMITKIGTTrackingToolboxView_h #include #include #include "ui_QmitkMITKIGTTrackingToolboxViewControls.h" //mitk headers #include #include #include #include //QT headers #include /*! \brief QmitkMITKIGTTrackingToolboxView \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup Functionalities */ class QmitkMITKIGTTrackingToolboxView : public QObject, public QmitkFunctionality { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; QmitkMITKIGTTrackingToolboxView(); virtual ~QmitkMITKIGTTrackingToolboxView(); virtual void CreateQtPartControl(QWidget *parent); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); protected slots: void OnLoadTools(); void OnStartTracking(); void OnStopTracking(); - void OnEnableLoggingClicked(); - void OnChooseFileClicked(); + + void StartLogging(); + + void StopLogging(); /** @brief Slot for tracking timer */ void UpdateTrackingTimer(); protected: Ui::QmitkMITKIGTTrackingToolboxViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; bool m_tracking; void MessageBox(std::string s); bool m_logging; - void StartLogging(); + int m_loggedFrames; - void StopLogging(); + mitk::DataNode::Pointer TrackingVolumeNode; //stores the loaded tools mitk::NavigationToolStorage::Pointer m_toolStorage; //members for the filter pipeline mitk::TrackingDeviceSource::Pointer m_TrackingDeviceSource; mitk::NavigationDataObjectVisualizationFilter::Pointer m_ToolVisualizationFilter; mitk::NavigationDataRecorder::Pointer m_loggingFilter; QTimer* m_TrackingTimer; }; #endif // _QMITKMITKIGTTRACKINGTOOLBOXVIEW_H_INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui index 47d9a92863..a640c6e97f 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui +++ b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui @@ -1,350 +1,454 @@ QmitkMITKIGTTrackingToolboxViewControls 0 0 335 685 0 0 QmitkTemplate 0 Tracking 0 280 16777215 280 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Tools</span></p></body></html> Loaded Tools: <none> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">(only load tool storage files which can be created </span></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">by the bundle &quot;NavigationToolManager&quot;)</span></p></body></html> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">with the bundle &quot;NavigationToolManager&quot;)</span></p></body></html> Qt::AlignJustify|Qt::AlignVCenter Qt::Horizontal 40 20 Load Tools <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Control</span></p></body></html> Status: <not configured> Qt::Horizontal 40 20 Start Tracking Qt::Horizontal 40 20 Stop Tracking Qt::Vertical 20 40 - Visualization Options + Options Show Tracking Volume + + true + + + + + + + Update Rate (Times Per Second) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 999 + + + 10 + + + + + Qt::Vertical 20 597 - Logging Options + Logging - - - - - Enable Logging - - - + Filename: C:/logfile.csv + + + + Choose File + + + - - - XML format - - + + + + + Limit Number Of Logged Frames: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + 9999 + + + 300 + + + + CSV format true + + + + XML format + + + + + + + Logging Status + + + + + + Logging OFF + + + + + + + Logged Frames: 0 + + + + + + Qt::Horizontal 40 20 - + - Choose File + Start Logging + + + + + + + Stop Logging Qt::Vertical 20 40 QmitkTrackingDeviceConfigurationWidget QWidget
QmitkTrackingDeviceConfigurationWidget.h
1
QmitkToolTrackingStatusWidget QWidget
QmitkToolTrackingStatusWidget.h
1
diff --git a/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.cpp b/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.cpp index 852e8829c7..6886cd2712 100644 --- a/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.cpp +++ b/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.cpp @@ -1,298 +1,306 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2007-12-11 14:46:19 +0100 (Di, 11 Dez 2007) $ Version: $Revision: 13129 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkNavigationDataRecorder.h" #include #include #include #include mitk::NavigationDataRecorder::NavigationDataRecorder() { //set default values m_NumberOfInputs = 0; m_RecordingMode = NormalFile; m_Recording = false; m_NumberOfRecordedFiles = 0; m_Stream = NULL; m_FileName = ""; m_SystemTimeClock = RealTimeClock::New(); m_OutputFormat = mitk::NavigationDataRecorder::xml; + m_RecordCounter = 0; + m_RecordCountLimit = -1; //To get a start time mitk::TimeStamp::GetInstance()->Start(this); } mitk::NavigationDataRecorder::~NavigationDataRecorder() { } void mitk::NavigationDataRecorder::GenerateData() { } void mitk::NavigationDataRecorder::AddNavigationData( const NavigationData* nd ) { // Process object is not const-correct so the const_cast is required here this->SetNthInput(m_NumberOfInputs, const_cast< mitk::NavigationData * >( nd ) ); m_NumberOfInputs++; this->Modified(); } void mitk::NavigationDataRecorder::SetRecordingMode( RecordingMode mode ) { m_RecordingMode = mode; this->Modified(); } void mitk::NavigationDataRecorder::Update() { if (m_Recording) { DataObjectPointerArray inputs = this->GetInputs(); //get all inputs mitk::NavigationData::TimeStampType timestamp=0.0; // timestamp for mitk time timestamp = mitk::TimeStamp::GetInstance()->GetElapsed(); mitk::NavigationData::TimeStampType sysTimestamp = 0.0; // timestamp for system time sysTimestamp = m_SystemTimeClock->GetCurrentStamp(); // cast system time double value to stringstream to avoid low precision rounding std::ostringstream strs; strs.precision(15); // rounding precision for system time double value strs << sysTimestamp; std::string sysTimeStr = strs.str(); //if csv-mode: write csv header and timpstamp at beginning if (m_OutputFormat == mitk::NavigationDataRecorder::csv) { //write header only when it's the first line if (m_firstLine) { m_firstLine = false; *m_Stream << "TimeStamp"; for (unsigned int index = 0; index < inputs.size(); index++){ *m_Stream << ";Valid_Tool" << index << ";X_Tool" << index << ";Y_Tool" << index << ";Z_Tool" << index << ";QX_Tool" << index << ";QY_Tool" << index << ";QZ_Tool" << index << ";QR_Tool" << index;} *m_Stream << "\n"; } //write timestamp (always) *m_Stream << timestamp; } //write tool data for every tool for (unsigned int index = 0; index < inputs.size(); index++) { mitk::NavigationData* nd = dynamic_cast(inputs[index].GetPointer()); nd->Update(); // call update to propagate update to previous filters mitk::NavigationData::PositionType position; mitk::NavigationData::OrientationType orientation(0.0, 0.0, 0.0, 0.0); mitk::NavigationData::CovarianceMatrixType matrix; bool hasPosition = true; bool hasOrientation = true; bool dataValid = false; position.Fill(0.0); matrix.SetIdentity(); position = nd->GetPosition(); orientation = nd->GetOrientation(); matrix = nd->GetCovErrorMatrix(); hasPosition = nd->GetHasPosition(); hasOrientation = nd->GetHasOrientation(); dataValid = nd->IsDataValid(); //use this one if you want the timestamps of the source //timestamp = nd->GetTimeStamp(); //a timestamp is never < 0! this case happens only if you are using the timestamp of the nd object instead of getting a new one if (timestamp >= 0) { if (this->m_OutputFormat == mitk::NavigationDataRecorder::xml) { TiXmlElement* elem = new TiXmlElement("ND"); elem->SetDoubleAttribute("Time", timestamp); elem->SetAttribute("SystemTime", sysTimeStr); // tag for system time elem->SetDoubleAttribute("Tool", index); elem->SetDoubleAttribute("X", position[0]); elem->SetDoubleAttribute("Y", position[1]); elem->SetDoubleAttribute("Z", position[2]); elem->SetDoubleAttribute("QX", orientation[0]); elem->SetDoubleAttribute("QY", orientation[1]); elem->SetDoubleAttribute("QZ", orientation[2]); elem->SetDoubleAttribute("QR", orientation[3]); elem->SetDoubleAttribute("C00", matrix[0][0]); elem->SetDoubleAttribute("C01", matrix[0][1]); elem->SetDoubleAttribute("C02", matrix[0][2]); elem->SetDoubleAttribute("C03", matrix[0][3]); elem->SetDoubleAttribute("C04", matrix[0][4]); elem->SetDoubleAttribute("C05", matrix[0][5]); elem->SetDoubleAttribute("C10", matrix[1][0]); elem->SetDoubleAttribute("C11", matrix[1][1]); elem->SetDoubleAttribute("C12", matrix[1][2]); elem->SetDoubleAttribute("C13", matrix[1][3]); elem->SetDoubleAttribute("C14", matrix[1][4]); elem->SetDoubleAttribute("C15", matrix[1][5]); if (dataValid) elem->SetAttribute("Valid",1); else elem->SetAttribute("Valid",0); if (hasOrientation) elem->SetAttribute("hO",1); else elem->SetAttribute("hO",0); if (hasPosition) elem->SetAttribute("hP",1); else elem->SetAttribute("hP",0); *m_Stream << " " << *elem << std::endl; delete elem; } else if (this->m_OutputFormat == mitk::NavigationDataRecorder::csv) { *m_Stream << ";" << dataValid << ";" << position[0] << ";" << position[1] << ";" << position[2] << ";" << orientation[0] << ";" << orientation[1] << ";" << orientation[2] << ";" << orientation[3]; } } } if (this->m_OutputFormat = mitk::NavigationDataRecorder::csv) *m_Stream << "\n"; } + m_RecordCounter++; + if ((m_RecordCountLimit<=m_RecordCounter)&&(m_RecordCountLimit != -1)) {StopRecording();} } void mitk::NavigationDataRecorder::StartRecording() { if (m_Recording) { std::cout << "Already recording please stop before start new recording session" << std::endl; return; } + + if (m_Stream == NULL) { std::stringstream ss; std::ostream* stream; //An existing extension will be cut and replaced with .xml std::string tmpPath = itksys::SystemTools::GetFilenamePath(m_FileName); m_FileName = itksys::SystemTools::GetFilenameWithoutExtension(m_FileName); if (m_OutputFormat == mitk::NavigationDataRecorder::csv) ss << tmpPath << "/" << m_FileName << "-" << m_NumberOfRecordedFiles << ".csv"; else ss << tmpPath << "/" << m_FileName << "-" << m_NumberOfRecordedFiles << ".xml"; switch(m_RecordingMode) { case Console: stream = &std::cout; break; case NormalFile: //Check if there is a file name and path if (m_FileName == "") { stream = &std::cout; std::cout << "No file name or file path set the output is redirected to the console"; } else { stream = new std::ofstream(ss.str().c_str()); } break; case ZipFile: stream = &std::cout; std::cout << "Sorry no ZipFile support yet"; break; default: stream = &std::cout; break; } m_firstLine = true; + m_RecordCounter = 0; StartRecording(stream); } } void mitk::NavigationDataRecorder::StartRecording(std::ostream* stream) { if (m_Recording) { std::cout << "Already recording please stop before start new recording session" << std::endl; return; } m_Stream = stream; m_Stream->precision(10); //TODO store date and GMT time if (m_Stream) { if (m_OutputFormat == mitk::NavigationDataRecorder::xml) { *m_Stream << "" << std::endl; /**m_Stream << "" << std::endl;*/ // should be a generic version, meaning a member variable, which has the actual version *m_Stream << " " << "" << std::endl; } m_Recording = true; } } void mitk::NavigationDataRecorder::StopRecording() { if (!m_Recording) { std::cout << "You have to start a recording first" << std::endl; return; } if ((m_Stream) && (m_OutputFormat == mitk::NavigationDataRecorder::xml)) { *m_Stream << "" << std::endl; } m_NumberOfRecordedFiles++; - m_Stream = NULL; m_Recording = false; + m_Stream->flush(); + m_Stream = NULL; } \ No newline at end of file diff --git a/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.h b/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.h index 2221fa121a..a7801a076c 100644 --- a/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.h +++ b/Modules/IGT/IGTFilters/mitkNavigationDataRecorder.h @@ -1,172 +1,186 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-02-08 13:23:19 +0100 (Fr, 08 Feb 2008) $ Version: $Revision: 13561 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_NavigationDataRecorder_H #define _MITK_NavigationDataRecorder_H #include #include "mitkNavigationData.h" #include #include namespace mitk { /**Documentation * \brief This class records NavigationData objects. * * The output of this class is formated as a XML document. * * Internal this class uses streams for recording NavigationData objects. Therefore different types of output are possible * and can be set with the SetOutputMode() method. The default output is directed to the console. If you want to save into a * file you have to set a file name and the path. The recording is started with the call of the method StartRecording(). Now * every Update() stores the current state of the added NavigationDatas. With StopRecording() the stream is stopped. With * another call of StartRecording() the output is written to a new file with incremented filename counter. * * \warning At the moment there is no check if the file is already existing and this class will override existing files. * \ingroup IGT */ class MitkIGT_EXPORT NavigationDataRecorder : public itk::ProcessObject { public: mitkClassMacro( NavigationDataRecorder, itk::ProcessObject ); itkNewMacro( Self ); /** * \brief sets the file name for the OutputMode NormalFile and ZipFile * * Any extensions will be cut * \warning existing files will be overridden * \warning do not use "." in file names at the end */ itkSetStringMacro(FileName); /** * \brief Returns the file name of the recording file (in OutputMode NormalFile and ZipFile) */ itkGetStringMacro(FileName); /** * \brief Returns whether the NavigationDataRecorder is recording or not */ itkGetMacro(Recording,bool); + /** + * \brief Returns the number of data sets / frames which were recorded by the NavigationDataRecorder since start + */ + itkGetMacro(RecordCounter,int); + + /** + * \brief Sets a limit of recorded data sets / frames. Recording will be stopped if the number is reached. -1 disables the limit, -1 is default value as well. + */ + itkSetMacro(RecordCountLimit,int); + /** * \brief Adds the input NavigationDatas */ virtual void AddNavigationData(const NavigationData* nd); /**Documentation * \brief Starts the recording with the presetted OutputMode * this method calls StartRecording(std::ostream*) */ void StartRecording(); /**Documentation * \brief Starts the recording with an own preinitialized stream */ void StartRecording(std::ostream* stream); /**Documentation * \brief Stops the recording and closes the stream */ void StopRecording(); /**Documentation * \brief Every call of update causes one line for each added NavigationData in the output if the recording was started */ virtual void Update(); /**Documentation * \brief Determines where the output is directed to * * Console: std::cout * NormalFile: std::ofstream * ZipFile: Not supported yet -> std::cout */ enum RecordingMode { Console, NormalFile, ZipFile }; /**Documentation * \brief Determines the output format * * xml: XML format, also default, can be read by NavigationDataPlayer * csv: use to export in excel, matlab, etc. */ enum OutputFormatEnum { xml, csv }; /**Documentation * \brief Sets the recording mode which causes different types of output streams * see enum RecordingMode */ void SetRecordingMode(RecordingMode mode); /**Documentation * \brief Sets the output format which causes different formats of output streams. The XML format is default. * Also see enum OutputFormat for more information. */ itkSetMacro(OutputFormat,mitk::NavigationDataRecorder::OutputFormatEnum); protected: /**Documentation * \brief filter execute method here it is not used * */ virtual void GenerateData(); NavigationDataRecorder(); virtual ~NavigationDataRecorder(); std::string m_FileName; ///< stores the file name and path unsigned int m_NumberOfInputs; ///< counts the numbers of added input NavigationDatas std::ostream* m_Stream; ///< the output stream RecordingMode m_RecordingMode; ///< stores the mode see enum RecordingMode OutputFormatEnum m_OutputFormat; ///< stores the output format; see enum OutputFormat bool m_Recording; ///< indicates whether the recording is started or not + int m_RecordCounter; ///< counts the number of frames which are recorded since StartRecording + + int m_RecordCountLimit; ///< limits the number of frames, recording will be stopped if the limit is reached. -1 disables the limit + bool m_firstLine; //for the csv writer to detect wether the header must be written unsigned int m_NumberOfRecordedFiles; ///< necessary for the naming of the file if there is more than one start-stop cycle mitk::RealTimeClock::Pointer m_SystemTimeClock; ///< system time clock for system time tag in output xml file }; } #endif // #define _MITK_POINT_SET_SOURCE_H diff --git a/Modules/OpenCVVideoSupport/mitkMovieGeneratorOpenCV.cpp b/Modules/OpenCVVideoSupport/mitkMovieGeneratorOpenCV.cpp index 93eee5ac46..a00b0f93e6 100644 --- a/Modules/OpenCVVideoSupport/mitkMovieGeneratorOpenCV.cpp +++ b/Modules/OpenCVVideoSupport/mitkMovieGeneratorOpenCV.cpp @@ -1,135 +1,136 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkMovieGeneratorOpenCV.h" -#include +//#include +#include "mitkGL.h" #include mitk::MovieGeneratorOpenCV::MovieGeneratorOpenCV() { m_initialized = false; m_aviWriter = NULL; m_dwRate = 20; m_FourCCCodec = NULL; m_RemoveColouredFrame = true; } void mitk::MovieGeneratorOpenCV::SetFileName( const char *fileName ) { m_sFile = fileName; } void mitk::MovieGeneratorOpenCV::SetFrameRate(int rate) { m_dwRate = rate; } void mitk::MovieGeneratorOpenCV::SetRemoveColouredFrame(bool RemoveColouredFrame) { m_RemoveColouredFrame = RemoveColouredFrame; } bool mitk::MovieGeneratorOpenCV::InitGenerator() { m_width = m_renderer->GetRenderWindow()->GetSize()[0]; // changed from glGetIntegerv( GL_VIEWPORT, viewport ); m_height = m_renderer->GetRenderWindow()->GetSize()[1]; // due to sometimes strange dimensions if(m_RemoveColouredFrame) { m_width -= 10; //remove colored boarders around renderwindows m_height -= 10; } m_width -= m_width % 4; // some video codecs have prerequisites to the image dimensions m_height -= m_height % 4; m_currentFrame = cvCreateImage(cvSize(m_width,m_height),8,3); // creating image with widget size, 8 bit per pixel and 3 channel r,g,b m_currentFrame->origin = 1; // avoid building a video with bottom up /* m_sFile = Name of the output video file. CV_FOURCC = 4-character code of codec used to compress the frames. For example, CV_FOURCC('P','I','M','1') is MPEG-1 codec, CV_FOURCC('M','J','P','G') is motion-jpeg codec etc. CV_FOURCC('P','I','M','1') = MPEG-1 codec CV_FOURCC('M','J','P','G') = motion-jpeg codec (does not work well) CV_FOURCC('M', 'P', '4', '2') = MPEG-4.2 codec CV_FOURCC('D', 'I', 'V', '3') = MPEG-4.3 codec CV_FOURCC('D', 'I', 'V', 'X') = MPEG-4 codec CV_FOURCC('U', '2', '6', '3') = H263 codec CV_FOURCC('I', '2', '6', '3') = H263I codec CV_FOURCC('F', 'L', 'V', '1') = FLV1 codec List of FOURCC codes is available at http://msdn2.microsoft.com/en-us/library/ms867195.aspx Under Win32 it is possible to pass -1 in order to choose compression method and additional compression parameters from dialog. m_dwRate = Framerate of the created video stream. frame_size Size of video frames. InitGenerator 1 = If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only).*/ if(m_FourCCCodec != NULL) { #ifdef WIN32 m_aviWriter = cvCreateVideoWriter(m_sFile.c_str(),CV_FOURCC(m_FourCCCodec[0],m_FourCCCodec[1],m_FourCCCodec[2], m_FourCCCodec[3]),m_dwRate,cvSize(m_width,m_height),1); //initializing video writer #else m_aviWriter = cvCreateVideoWriter(m_sFile.c_str(),CV_FOURCC(m_FourCCCodec[0],m_FourCCCodec[1],m_FourCCCodec[2], m_FourCCCodec[3]),m_dwRate,cvSize(m_width,m_height)); //initializing video writer #endif } else { #ifdef WIN32 m_aviWriter = cvCreateVideoWriter(m_sFile.c_str(),-1,m_dwRate,cvSize(m_width,m_height),1); //initializing video writer #else m_aviWriter = cvCreateVideoWriter(m_sFile.c_str(),CV_FOURCC('X','V','I','D'),m_dwRate,cvSize(m_width,m_height)); //initializing video writer #endif } if(!m_aviWriter) { std::cout << "errors initializing video writer...correct video file path? on linux: ffmpeg must be included in OpenCV."; return false; } return true; } bool mitk::MovieGeneratorOpenCV::AddFrame( void *data ) { //cvSetImageData(m_currentFrame,data,m_width*3); memcpy(m_currentFrame->imageData,data,m_width*m_height*3); cvWriteFrame(m_aviWriter,m_currentFrame); return true; } bool mitk::MovieGeneratorOpenCV::TerminateGenerator() { if (m_aviWriter) { cvReleaseVideoWriter(&m_aviWriter); } return true; } diff --git a/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerControllerTest.cpp b/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerControllerTest.cpp index f571b55e58..d02b29711b 100644 --- a/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerControllerTest.cpp +++ b/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerControllerTest.cpp @@ -1,73 +1,76 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-12 14:05:50 +0100 (Fr, 12 Mrz 2010) $ Version: $Revision: 16010 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkToFConfig.h" #include #include #include #include /**Documentation * test for the class "ToFCameraPMDPlayerController". */ int mitkToFCameraPMDPlayerControllerTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("ToFCameraPMDPlayerController"); //initialize test mitk::ToFCameraPMDPlayerDevice::Pointer pmdPlayerDevice = mitk::ToFCameraPMDPlayerDevice::New(); mitk::ToFCameraPMDPlayerController::Pointer testObject = mitk::ToFCameraPMDPlayerController::New(); MITK_TEST_CONDITION_REQUIRED( !(testObject.GetPointer() == NULL),"Testing object initialization!"); MITK_TEST_CONDITION_REQUIRED( testObject->GetCaptureHeight()== 200,"Testing member variable init 1!"); MITK_TEST_CONDITION_REQUIRED( testObject->GetCaptureWidth() == 200 ,"Testing member variable init 2!"); //testing the creation of a connection without valid data MITK_TEST_CONDITION_REQUIRED( !testObject->OpenCameraConnection(),"Testing OpenConnection without valid data!"); MITK_TEST_CONDITION_REQUIRED( testObject->GetIntegrationTime() == 0, "Testing passing of integration time from PMD data!"); MITK_TEST_CONDITION_REQUIRED( testObject->GetModulationFrequency() == 0, "Testing passing of modulation frequency from PMD data!"); // set some valid data and test connecting again! TODO: Set the data to generic dir!! std::string filePath = MITK_TOF_DATA_DIR; std::string fileName = "/TestSequence.pmd"; filePath.append(fileName); pmdPlayerDevice->SetStringProperty("PMDFileName", filePath.c_str()); testObject = dynamic_cast(pmdPlayerDevice->GetController().GetPointer()); // current implementation for mitkToFCameraPMDPlayerController only works for 32 bit machines, so we need to check // the platform we are working on! std::string platformVar = MITK_TOF_PLATFORM; - if( platformVar == "W32") + if( platformVar == "W32") { - MITK_TEST_CONDITION_REQUIRED( testObject->OpenCameraConnection(),"Testing OpenConnection with valid data!"); - MITK_TEST_CONDITION_REQUIRED( !testObject->GetIntegrationTime() == 0, "Testing passing of integration time from PMD data!"); - MITK_TEST_CONDITION_REQUIRED( !testObject->GetModulationFrequency() == 0, "Testing passing of modulation frequency from PMD data!"); + if(std::string(MITK_TOF_PMDFILE_SOURCE_PLUGIN) != "") + { + MITK_TEST_CONDITION_REQUIRED( testObject->OpenCameraConnection(),"Testing OpenConnection with valid data!"); + MITK_TEST_CONDITION_REQUIRED( !testObject->GetIntegrationTime() == 0, "Testing passing of integration time from PMD data!"); + MITK_TEST_CONDITION_REQUIRED( !testObject->GetModulationFrequency() == 0, "Testing passing of modulation frequency from PMD data!") + } // testing disconnection MITK_TEST_CONDITION_REQUIRED ( testObject->CloseCameraConnection(), "Testing CloseConnection with data!"); } else { MITK_TEST_CONDITION_REQUIRED( true, "Test case skipped! Wrong platfrom configuration, no driver available!"); } // test end MITK_TEST_END(); } diff --git a/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerDeviceTest.cpp b/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerDeviceTest.cpp index 15dcb9be33..03b683ee36 100644 --- a/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerDeviceTest.cpp +++ b/Modules/ToFHardware/Testing/mitkToFCameraPMDPlayerDeviceTest.cpp @@ -1,61 +1,64 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-12 14:05:50 +0100 (Fr, 12 Mrz 2010) $ Version: $Revision: 16010 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include /**Documentation * test for the class "ToFCameraPMDPlayerDevice". */ int mitkToFCameraPMDPlayerDeviceTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("ToFCameraPMDPlayerDevice"); std::string fileName = MITK_TOF_DATA_DIR; fileName = fileName + "/TestSequence.pmd"; mitk::ToFCameraPMDPlayerDevice::Pointer tofCameraPMDPlayerDevice = mitk::ToFCameraPMDPlayerDevice::New(); tofCameraPMDPlayerDevice->SetProperty("PMDFileName",mitk::StringProperty::New(fileName)); std::string platform = MITK_TOF_PLATFORM; // PMDPlayerController only available for W32 systems if (platform=="W32") { - MITK_TEST_CONDITION_REQUIRED(tofCameraPMDPlayerDevice->ConnectCamera(),"Test ConnectCamera()"); + if(std::string(MITK_TOF_PMDFILE_SOURCE_PLUGIN) != "") + { + MITK_TEST_CONDITION_REQUIRED(tofCameraPMDPlayerDevice->ConnectCamera(),"Test ConnectCamera()"); + } tofCameraPMDPlayerDevice->StartCamera(); tofCameraPMDPlayerDevice->UpdateCamera(); float* distances = new float[40000]; float* amplitudes = new float[40000]; float* intensities = new float[40000]; int imageSequence = 0; MITK_TEST_OUTPUT(<<"Call GetDistances()"); tofCameraPMDPlayerDevice->GetDistances(distances,imageSequence); MITK_TEST_OUTPUT(<<"Call GetAmplitudes()"); tofCameraPMDPlayerDevice->GetAmplitudes(amplitudes,imageSequence); MITK_TEST_OUTPUT(<<"Call GetIntensities()"); tofCameraPMDPlayerDevice->GetIntensities(intensities,imageSequence); tofCameraPMDPlayerDevice->StopCamera(); MITK_TEST_CONDITION_REQUIRED(tofCameraPMDPlayerDevice->DisconnectCamera(),"Test DisconnectCamera()"); delete[] distances; delete[] amplitudes; delete[] intensities; } MITK_TEST_END(); } diff --git a/SuperBuild.cmake b/SuperBuild.cmake index 6d9710ec38..a433482fa9 100644 --- a/SuperBuild.cmake +++ b/SuperBuild.cmake @@ -1,238 +1,241 @@ #----------------------------------------------------------------------------- # Convenient macro allowing to download a file #----------------------------------------------------------------------------- MACRO(downloadFile url dest) FILE(DOWNLOAD ${url} ${dest} STATUS status) LIST(GET status 0 error_code) LIST(GET status 1 error_msg) IF(error_code) MESSAGE(FATAL_ERROR "error: Failed to download ${url} - ${error_msg}") ENDIF() ENDMACRO() #----------------------------------------------------------------------------- # MITK Prerequisites #----------------------------------------------------------------------------- #----------------------------- Qt --------------------------- if(MITK_USE_QT) find_package(Qt4 REQUIRED) set(vtk_QT_ARGS -DDESIRED_QT_VERSION:STRING=4 -DVTK_USE_GUISUPPORT:BOOL=ON -DVTK_USE_QVTK_QTOPENGL:BOOL=ON -DVTK_USE_QT:BOOL=ON -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} ) endif() #----------------------------------------------------------------------------- # External project settings #----------------------------------------------------------------------------- INCLUDE(ExternalProject) SET(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals") SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) SET(ep_install_dir ${ep_base}/Install) #SET(ep_build_dir ${ep_base}/Build) SET(ep_source_dir ${ep_base}/Source) #SET(ep_parallelism_level) SET(ep_build_shared_libs ON) SET(ep_build_testing OFF) # Compute -G arg for configuring external projects with the same CMake generator: IF(CMAKE_EXTRA_GENERATOR) SET(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") ELSE() SET(gen "${CMAKE_GENERATOR}") ENDIF() # Use this value where semi-colons are needed in ep_add args: set(sep "^^") ## IF(MSVC90 OR MSVC10) SET(ep_common_C_FLAGS "${CMAKE_C_FLAGS} /bigobj /MP") SET(ep_common_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /MP") ELSE() SET(ep_common_C_FLAGS "${CMAKE_C_FLAGS} -DLINUX_EXTRA") SET(ep_common_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX_EXTRA") ENDIF() SET(ep_common_args -DBUILD_TESTING:BOOL=${ep_build_testing} -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir} -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} -DCMAKE_C_FLAGS:STRING=${ep_common_C_FLAGS} -DCMAKE_CXX_FLAGS:STRING=${ep_common_CXX_FLAGS} #debug flags -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG} #release flags -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE} #relwithdebinfo -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO} ) #----------------------------------------------------------------------------- # ExternalProjects #----------------------------------------------------------------------------- SET(external_projects VTK GDCM ITK Boost DCMTK CTK OpenCV MITKData ) # Include external projects FOREACH(p ${external_projects}) INCLUDE(CMakeExternals/${p}.cmake) ENDFOREACH() #----------------------------------------------------------------------------- # Set superbuild boolean args #----------------------------------------------------------------------------- SET(mitk_cmake_boolean_args BUILD_SHARED_LIBS WITH_COVERAGE BUILD_TESTING MITK_USE_QT MITK_INSTALL_RPATH_RELATIVE MITK_BUILD_ALL_PLUGINS MITK_BUILD_TUTORIAL MITK_USE_Boost MITK_USE_BLUEBERRY MITK_USE_CTK MITK_USE_DCMTK MITK_USE_OpenCV ) #----------------------------------------------------------------------------- # Generate cmake variable names for MITK bundles #----------------------------------------------------------------------------- INCLUDE(mitkSuperBuildPlugins) FOREACH(plugin ${MITK_SUPERBUILD_PLUGINS}) LIST(APPEND mitk_cmake_boolean_args MITK_BUILD_${plugin}) OPTION(MITK_BUILD_${plugin} "Build the MITK ${plugin} plugin" OFF) ENDFOREACH() #----------------------------------------------------------------------------- # Create the final variable containing superbuild boolean args #----------------------------------------------------------------------------- SET(mitk_superbuild_boolean_args) FOREACH(mitk_cmake_arg ${mitk_cmake_boolean_args}) LIST(APPEND mitk_superbuild_boolean_args -D${mitk_cmake_arg}:BOOL=${${mitk_cmake_arg}}) ENDFOREACH() IF(MITK_BUILD_ALL_PLUGINS) LIST(APPEND mitk_superbuild_boolean_args -DBLUEBERRY_BUILD_ALL_PLUGINS:BOOL=ON) ENDIF() #----------------------------------------------------------------------------- # MITK Utilities #----------------------------------------------------------------------------- set(proj MITK-Utilities) ExternalProject_Add(${proj} DOWNLOAD_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS # Mandatory dependencies ${VTK_DEPENDS} ${ITK_DEPENDS} # Optionnal dependencies ${Boost_DEPENDS} ${CTK_DEPENDS} ${DCMTK_DEPENDS} ${OpenCV_DEPENDS} ${MITK-Data_DEPENDS} ) #----------------------------------------------------------------------------- # MITK Configure #----------------------------------------------------------------------------- IF(MITK_INITIAL_CACHE_FILE) SET(mitk_initial_cache_arg -C "${MITK_INITIAL_CACHE_FILE}") ENDIF() SET(proj MITK-Configure) ExternalProject_Add(${proj} DOWNLOAD_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${mitk_superbuild_boolean_args} -DMITK_USE_SUPERBUILD:BOOL=OFF + -DMITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DMITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DMITK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${MITK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY} -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS} -DMITK_SUPERBUILD_BINARY_DIR:PATH=${MITK_BINARY_DIR} -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DMITK_KWSTYLE_EXECUTABLE:FILEPATH=${MITK_KWSTYLE_EXECUTABLE} -DCTK_DIR:PATH=${CTK_DIR} -DDCMTK_DIR:PATH=${DCMTK_DIR} -DVTK_DIR:PATH=${VTK_DIR} # FindVTK expects VTK_DIR -DITK_DIR:PATH=${ITK_DIR} # FindITK expects ITK_DIR -DOpenCV_DIR:PATH=${OpenCV_DIR} -DGDCM_DIR:PATH=${GDCM_DIR} -DBOOST_ROOT:PATH=${BOOST_ROOT} -DMITK_DATA_DIR:PATH=${MITK_DATA_DIR} ${mitk_initial_cache_arg} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} BINARY_DIR ${CMAKE_BINARY_DIR}/MITK-build BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS MITK-Utilities ) #----------------------------------------------------------------------------- # MITK #----------------------------------------------------------------------------- #MESSAGE(STATUS SUPERBUILD_EXCLUDE_MITKBUILD_TARGET:${SUPERBUILD_EXCLUDE_MITKBUILD_TARGET}) IF(NOT DEFINED SUPERBUILD_EXCLUDE_MITKBUILD_TARGET OR NOT SUPERBUILD_EXCLUDE_MITKBUILD_TARGET) SET(proj MITK-build) ExternalProject_Add(${proj} DOWNLOAD_COMMAND "" CMAKE_GENERATOR ${gen} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} BINARY_DIR MITK-build INSTALL_COMMAND "" DEPENDS "MITK-Configure" ) ENDIF() #----------------------------------------------------------------------------- # Custom target allowing to drive the build of MITK project itself #----------------------------------------------------------------------------- ADD_CUSTOM_TARGET(MITK COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/MITK-build WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/MITK-build )