diff --git a/CMake/MITKDashboardDriverScript.cmake b/CMake/MITKDashboardDriverScript.cmake new file mode 100644 index 0000000000..09773cd1a7 --- /dev/null +++ b/CMake/MITKDashboardDriverScript.cmake @@ -0,0 +1,239 @@ + +# +# 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 + ADDITIONNAL_CMAKECACHE_OPTION + 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_PROJECT_NAME + CTEST_SOURCE_DIRECTORY + CTEST_BINARY_DIRECTORY + CTEST_BUILD_NAME + SCRIPT_MODE + CTEST_COVERAGE_COMMAND + CTEST_MEMORYCHECK_COMMAND + CTEST_GIT_COMMAND + QT_QMAKE_EXECUTABLE + ) +if(WITH_DOCUMENTATION) + list(APPEND expected_variables DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY) +endif() + +foreach(var ${expected_variables}) + if(NOT DEFINED ${var}) + message(FATAL_ERROR "Variable ${var} should be defined in top-level script !") + endif() +endforeach() + +# If the dashscript doesn't define a GIT_REPOSITORY variable, let's define it here. +if (NOT DEFINED GIT_REPOSITORY OR GIT_REPOSITORY STREQUAL "") + set(GIT_REPOSITORY git@mbits:MITK) +endif() + +# Should binary directory be cleaned? +set(empty_binary_directory FALSE) + +# Attempt to build and test also if 'ctest_update' returned an error +set(force_build FALSE) + +# Set model options +set(model "") +if (SCRIPT_MODE STREQUAL "experimental") + set(empty_binary_directory FALSE) + set(force_build TRUE) + set(model Experimental) +elseif (SCRIPT_MODE STREQUAL "continuous") + set(empty_binary_directory TRUE) + set(force_build FALSE) + set(model Continuous) +elseif (SCRIPT_MODE STREQUAL "nightly") + set(empty_binary_directory TRUE) + set(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:${force_build}") + +set(CTEST_USE_LAUNCHERS 1) + +if(empty_binary_directory) + message("Directory ${CTEST_BINARY_DIRECTORY} cleaned !") + ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) +endif() + +if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone ${GIT_REPOSITORY} ${CTEST_SOURCE_DIRECTORY}") +endif() + +set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") + +# +# run_ctest macro +# +MACRO(run_ctest) + ctest_start(${model}) + ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) + + # 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 +BLUEBERRY_BUILD_ALL_PLUGINS:BOOL=TRUE +MITK_BUILD_ALL_PLUGINS:BOOL=TRUE +CMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} +QT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} +SUPERBUILD_EXCLUDE_MITKBUILD_TARGET:BOOL=TRUE +WITH_COVERAGE:BOOL=${WITH_COVERAGE} +#DOCUMENTATION_TARGET_IN_ALL:BOOL=${WITH_DOCUMENTATION} +DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY:PATH=${DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY} +${ADDITIONNAL_CMAKECACHE_OPTION} +") + endif() + + if (res GREATER 0 OR force_build) + + ctest_submit(PARTS Update) + + message("Configure SuperBuild") + + set_property(GLOBAL PROPERTY SubProject SuperBuild) + set_property(GLOBAL PROPERTY Label SuperBuild) + + ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}") + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_submit(PARTS Configure) + ctest_submit(FILES "${CTEST_BINARY_DIRECTORY}/Project.xml") + + # Build top level + message("----------- [ Build SuperBuild ] -----------") + ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) + ctest_submit(PARTS Build) + + ctest_test( + BUILD "${CTEST_BINARY_DIRECTORY}" + INCLUDE_LABEL "SuperBuild" + PARALLEL_LEVEL 8 + EXCLUDE ${TEST_TO_EXCLUDE_REGEX}) + # runs only tests that have a LABELS property matching "${subproject}" + ctest_submit(PARTS Test) + + set(mitk_build_dir "${CTEST_BINARY_DIRECTORY}/MITK-build") + + set(CTEST_PROJECT_SUBPROJECTS MITK) + + foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) + set_property(GLOBAL PROPERTY SubProject ${subproject}) + set_property(GLOBAL PROPERTY Label ${subproject}) + message("----------- [ Build ${subproject} ] -----------") + + # Configure target + ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}") + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_submit(PARTS Configure) + + # Build target + set(CTEST_BUILD_TARGET "${subproject}") + ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) + ctest_submit(PARTS Build) + + message("----------- [ Test ${subproject} ] -----------") + + ctest_test( + BUILD "${mitk_build_dir}" + APPEND + # INCLUDE_LABEL "${subproject}" + PARALLEL_LEVEL 8 + EXCLUDE ${TEST_TO_EXCLUDE_REGEX}) + # runs only tests that have a LABELS property matching "${subproject}" + + ctest_submit(PARTS Test) + + # Coverage per sub-project + if (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND) + message("----------- [ Coverage ${subproject} ] -----------") + ctest_coverage(BUILD "${mitk_build_dir}") # LABELS "${subproject}") + ctest_submit(PARTS Coverage) + endif () + + #if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND) + # ctest_memcheck(BUILD "${mitk_build_dir}" INCLUDE_LABEL "${subproject}") + # ctest_submit(PARTS MemCheck) + #endif () + 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) + set(CTEST_BUILD_TARGET "doc") + ctest_build(BUILD "${mitk_build_dir}" APPEND) + ctest_submit(PARTS Build) + set(CTEST_USE_LAUNCHERS 1) + endif() + + # HACK Unfortunately ctest_coverage ignores the build argument, try to force it... + file(READ ${mitk_build_dir}/CMakeFiles/TargetDirectories.txt mitk_build_coverage_dirs) + file(APPEND "${CTEST_BINARY_DIRECTORY}/CMakeFiles/TargetDirectories.txt" "${mitk_build_coverage_dirs}") + + 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 "${mitk_build_dir}" APPEND) + ctest_submit(PARTS Coverage) + endif () + + # Global dynamic analysis ... + if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND) + message("----------- [ Global memcheck ] -----------") + ctest_memcheck(BUILD "${mitk_build_dir}") + ctest_submit(PARTS MemCheck) + endif () + + # Note should be at the end + ctest_submit(PARTS Notes) + + endif() +endmacro() + +if(SCRIPT_MODE STREQUAL "continuous") + while(${CTEST_ELAPSED_TIME} LESS 68400) + set(START_TIME ${CTEST_ELAPSED_TIME}) + run_ctest() + # Loop no faster than once every 5 minutes + message("Wait for 5 minutes ...") + ctest_sleep(${START_TIME} 300 ${CTEST_ELAPSED_TIME}) + endwhile() +else() + run_ctest() +endif() + diff --git a/CMake/MITKDashboardScript.TEMPLATE.cmake b/CMake/MITKDashboardScript.TEMPLATE.cmake new file mode 100644 index 0000000000..c30c3fea44 --- /dev/null +++ b/CMake/MITKDashboardScript.TEMPLATE.cmake @@ -0,0 +1,113 @@ +# +# OS: Ubuntu 9.04 2.6.28-18-generic +# Hardware: x86_64 GNU/Linux +# GPU: NA +# + +# Note: The specific version and processor type of this machine should be reported in the +# header above. Indeed, this file will be send to the dashboard as a NOTE file. + +cmake_minimum_required(VERSION 2.8.2) + +# +# Dashboard properties +# +set(MY_OPERATING_SYSTEM "Linux") # Windows, Linux, Darwin... +set(MY_COMPILER "g++4.3.3") +set(MY_QT_VERSION "4.6.2") +set(QT_QMAKE_EXECUTABLE "$ENV{QTDIR}/bin/qmake") +set(CTEST_SITE "mbi007") # for example: mymachine.kitware, mymachine.dkfz, ... +set(CTEST_DASHBOARD_ROOT "/opt/dartclients") +set(CTEST_CMAKE_COMMAND "/usr/bin/cmake") +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") + +# +# Dashboard options +# +set(WITH_KWSTYLE FALSE) +set(WITH_MEMCHECK FALSE) +set(WITH_COVERAGE TRUE) +set(WITH_DOCUMENTATION FALSE) +#set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ) # for example: $ENV{HOME}/Projects/Doxygen +set(CTEST_BUILD_CONFIGURATION "Release") +set(CTEST_TEST_TIMEOUT 500) +set(CTEST_BUILD_FLAGS "-j4") # Use multiple CPU cores to build + +# experimental: +# - run_ctest() macro will be called *ONE* time +# - binary directory will *NOT* be cleaned +# continuous: +# - run_ctest() macro will be called EVERY 5 minutes ... +# - binary directory will *NOT* be cleaned +# - configure/build will be executed *ONLY* if the repository has been updated +# nightly: +# - run_ctest() macro will be called *ONE* time +# - binary directory *WILL BE* cleaned +set(SCRIPT_MODE "experimental") # "experimental", "continuous", "nightly" + +# +# Project specific properties +# +set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/MITK") +set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/MITK-Superbuild-${CTEST_BUILD_CONFIGURATION}-${SCRIPT_MODE}") + +set(ADDITIONNAL_CMAKECACHE_OPTION " +#MITK_USE_Boost:BOOL=ON +") + +# List of test that should be explicitly disabled on this machine +set(TEST_TO_EXCLUDE_REGEX "") + +# set any extra environment variables here +set(ENV{DISPLAY} ":0") + +find_program(CTEST_COVERAGE_COMMAND NAMES gcov) +find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) +find_program(CTEST_GIT_COMMAND NAMES git) + +# +# Git repository - Overwrite the default value provided by the driver script +# +# set(GIT_REPOSITORY "/home/username/MITK") + +########################################## +# WARNING: DO NOT EDIT BEYOND THIS POINT # +########################################## + +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +# +# Project specific properties +# +set(CTEST_PROJECT_NAME "MITK") +set(CTEST_BUILD_NAME "${MY_OPERATING_SYSTEM}-${MY_COMPILER}-QT${MY_QT_VERSION}-${CTEST_BUILD_CONFIGURATION}") + +# +# Display build info +# +message("site name: ${CTEST_SITE}") +message("build name: ${CTEST_BUILD_NAME}") +message("script mode: ${SCRIPT_MODE}") +message("coverage: ${WITH_COVERAGE}, memcheck: ${WITH_MEMCHECK}") + +# +# 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() + +# +# Download and include dashboard driver script +# +set(url file:///home/zelzer/git/MITK/CMake/MITKDashboardDriverScript.cmake) +set(dest ${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}.driver) +downloadFile(${url} ${dest}) +INCLUDE(${dest}) + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e8773a5ac..8b5a6ebe9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,402 +1,405 @@ cmake_minimum_required(VERSION 2.8.2) project(MITK) #----------------------------------------------------------------------------- # 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) #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) #----------------------------------------------------------------------------- # 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}]") 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_GDCMIO "Use the GDCMIO class instead of ImageIO2 for DICOM" ON) 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) 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) #----------------------------------------------------------------------------- # 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(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) #----------------------------------------------------------------------------- # 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 "${CMAKE_C_FLAGS} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}") set(MITK_CXX_FLAGS "${CMAKE_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) #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) # 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() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) endif() #----------------------------------------------------------------------------- # 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 ${MITK_CXX_FLAGS}) set(CMAKE_C_FLAGS ${MITK_C_FLAGS}) if(MITK_USE_QT) add_definitions(-DQWT_DLL) endif() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- link_directories(${MITK_LINK_DIRECTORIES}) add_subdirectory(Core) add_subdirectory(CoreUI) add_subdirectory(Modules) add_subdirectory(Applications) #----------------------------------------------------------------------------- # 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() #----------------------------------------------------------------------------- # 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 #----------------------------------------------------------------------------- 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) +# Project.xml for CDash +CONFIGURE_FILE(MITKProject.xml "${MITK_BINARY_DIR}/Project.xml" COPYONlY) + 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 new file mode 100644 index 0000000000..9643bb76ad --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1,8 @@ +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/DartConfig.cmake b/DartConfig.cmake deleted file mode 100644 index 25414b1c86..0000000000 --- a/DartConfig.cmake +++ /dev/null @@ -1,75 +0,0 @@ -OPTION(USE_MITK_ORG_DASHBOARD "Use the dartboard on mitk.org for build submissions." OFF) - -# internal cdash -set(CTEST_PROJECT_NAME "MITK") -set(CTEST_NIGHTLY_START_TIME "21:00:00 CEST") -set(NIGHTLY_START_TIME "21:00:00 CEST") - -set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "mbits") -set(CTEST_DROP_LOCATION "/cdash/submit.php?project=MITK") -set(CTEST_DROP_SITE_CDASH TRUE) -set(DROP_METHOD "http") -set(DROP_SITE "mbits") -set(DROP_LOCATION "/cdash/submit.php?project=MITK") - - -# configure dart for submission to kitware -IF(USE_MITK_ORG_DASHBOARD) -# -# Dart server to submit results (used by client) -# - SET(DROP_METHOD "http") - SET(DROP_SITE "cdash.mitk.org") - SET(DROP_LOCATION "/submit.php?project=MITK") - 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) - - SET(CTEST_NIGHTLY_START_TIME "21:00 CEST") - SET (NIGHTLY_START_TIME "21:00:00 CEST") - - SET (DOXYGEN_URL "http://docs.mitk.org/nightly-qt4/" ) - -ENDIF(USE_MITK_ORG_DASHBOARD) - -IF(EXISTS ${MBI_DART_WORKDIR}/notes.txt) - MAKE_DIRECTORY(${MBI_DART_WORKDIR}/bin/Testing/Notes) - CONFIGURE_FILE(${MBI_DART_WORKDIR}/notes.txt ${MBI_DART_WORKDIR}/bin/Testing/Notes/notes.txt COPYONLY) -ENDIF(EXISTS ${MBI_DART_WORKDIR}/notes.txt) -IF(EXISTS ${ITK_DIR}/ITKConfig.cmake) - INCLUDE(${ITK_DIR}/ITKConfig.cmake) -ENDIF(EXISTS ${ITK_DIR}/ITKConfig.cmake) - -IF(EXISTS ${VTK_DIR}/VTKConfig.cmake) - # this second check is necessary since sometimes on the very first - # CMake run VTKConfig exists but VTKConfigQt doesn't exist yet, breaking the - # configure step - IF(EXISTS ${VTK_DIR}/VTKConfigQt.cmake) - INCLUDE(${VTK_DIR}/VTKConfig.cmake) - ENDIF(EXISTS ${VTK_DIR}/VTKConfigQt.cmake) -ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake) - -IF(CMAKE_COMPILER_IS_GNUCXX) - MESSAGE(STATUS "Compiler is GCC") - EXEC_PROGRAM(${CMAKE_CXX_COMPILER} - ARGS --version - OUTPUT_VARIABLE COMPILER_OUTPUT - ) -ENDIF(CMAKE_COMPILER_IS_GNUCXX) -MESSAGE(STATUS "Compiler version output: ${COMPILER_OUTPUT}") - -SET(BUILD_NOTES_DIR ${PROJECT_BINARY_DIR}/Testing/Notes) -MAKE_DIRECTORY(${BUILD_NOTES_DIR}) -SET(BUILD_NOTES_FILE ${BUILD_NOTES_DIR}/build-notes.txt) -FILE(WRITE ${BUILD_NOTES_FILE} "Toolkit versions for this build: -ITK_DIR: ${ITK_DIR} -VTK_DIR: ${VTK_DIR} -VTK version: ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION} -ITK version: ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH} -COMPILER output string: ${COMPILER_OUTPUT} -") - -# if we are part of a larger project, they maybe use other Dart configuration -INCLUDE(../DartConfig.cmake OPTIONAL) diff --git a/MITKProject.xml b/MITKProject.xml new file mode 100644 index 0000000000..8a6597760f --- /dev/null +++ b/MITKProject.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/MITKSuperBuild.xml b/MITKSuperBuild.xml new file mode 100644 index 0000000000..99a752541d --- /dev/null +++ b/MITKSuperBuild.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/SuperBuild.cmake b/SuperBuild.cmake index ca73ff258d..fe2866e94a 100644 --- a/SuperBuild.cmake +++ b/SuperBuild.cmake @@ -1,227 +1,232 @@ #----------------------------------------------------------------------------- # 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 ${ep_common_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_FLAGS:STRING=${ep_common_CXX_FLAGS}" "-DCMAKE_CXX_FLAGS:STRING=${ep_common_CXX_FLAGS}" ) #----------------------------------------------------------------------------- # ExternalProjects #----------------------------------------------------------------------------- SET(external_projects VTK GDCM ITK Boost DCMTK CTK ) # 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_GDCMIO MITK_USE_BLUEBERRY MITK_USE_CTK MITK_USE_DCMTK ) #----------------------------------------------------------------------------- # 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} ) #----------------------------------------------------------------------------- # MITK Configure #----------------------------------------------------------------------------- SET(proj MITK-Configure) ExternalProject_Add(${proj} DOWNLOAD_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${mitk_superbuild_boolean_args} -DMITK_USE_SUPERBUILD:BOOL=OFF -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS} -DMITK_SUPERBUILD_BINARY_DIR:PATH=${MITK_BINARY_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} "-DCMAKE_CXX_FLAGS:STRING=${ep_common_CXX_FLAGS} ${MITK_CXX_FLAGS}" "-DCMAKE_C_FLAGS:STRING=${ep_common_C_FLAGS} ${MITK_C_FLAGS}" -DMITK_CXX_FLAGS:STRING=${MITK_CXX_FLAGS} -DMITK_C_FLAGS:STRING=${MITK_C_FLAGS} -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 -DGDCM_DIR:PATH=${GDCM_DIR} -DBOOST_ROOT:PATH=${BOOST_ROOT} -DMITK_USE_Boost:BOOL=${MITK_USE_Boost} -DMITK_USE_GDCMIO:BOOL=${MITK_USE_GDCMIO} -DMITK_USE_DCMTK:BOOL=${MITK_USE_DCMTK} -DMITK_USE_QT:BOOL=${MITK_USE_QT} 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 ) - + +#----------------------------------------------------------------------------- +# Project.xml for CDash +#----------------------------------------------------------------------------- + +CONFIGURE_FILE(MITKSuperBuild.xml "${MITK_BINARY_DIR}/Project.xml" COPYONlY)