From: Vivien Delmon Date: Tue, 13 Dec 2011 13:06:19 +0000 (+0100) Subject: Factorize CMakeLists X-Git-Tag: v1.3.0~142 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3b74618a8efd24d3d277c75fda1ddc4b2f104d51;p=clitk.git Factorize CMakeLists - Factorize CMakeLists to allow their use in other projects. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fd3ea26..75f52c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,126 +6,18 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) PROJECT(clitk) +SET(CLITK_SOURCE_DIR ${PROJECT_SOURCE_DIR}) #========================================================= #========================================================= INCLUDE(cmake/common.cmake) +INCLUDE(cmake/dependencies.cmake) +INCLUDE(cmake/build_opt.cmake) #========================================================= - -#========================================================= -#Support for the CTest dashboard testing system -OPTION(BUILD_TESTING "Build the testing tree" OFF) -IF (BUILD_TESTING) - OPTION(CLITK_BUILD_TESTING "Test ITK" ON) - INCLUDE(CTest) -ENDIF(BUILD_TESTING) -#========================================================= - -#========================================================= -# Find ITK (required) -FIND_PACKAGE(ITK) -IF(ITK_FOUND) - INCLUDE("${ITK_USE_FILE}") -ELSE(ITK_FOUND) - MESSAGE(FATAL_ERROR "Cannot build without ITK. Please set ITK_DIR.") -ENDIF(ITK_FOUND) -#========================================================= - -#========================================================= -# Find VTK (required) -FIND_PACKAGE(VTK REQUIRED) -IF(VTK_FOUND) - INCLUDE("${VTK_USE_FILE}") -ELSE(VTK_FOUND) - MESSAGE(FATAL_ERROR "Please set VTK_DIR.") -ENDIF(VTK_FOUND) -#========================================================= - -#========================================================= -# Find gengetopt, will create a target exe if not found -SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -FIND_PACKAGE(Gengetopt) -#========================================================= - -#========================================================= -# Find libstatgrab is installed, add clitkMemoryUsage.cxx in the library -FIND_LIBRARY(LIBSTATGRAB NAMES statgrab PATHS) -IF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") -# MESSAGE("Install libstatgrab (http://www.i-scream.org/libstatgrab/) for memory usage information") - SET(CLITK_MEMORY_INFO OFF) -ELSE (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") - SET(CLITK_MEMORY_INFO ON) -ENDIF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") #========================================================= -#========================================================= -# If the user choose to build documentation, then search for Doxygen executables. -OPTION(BUILD_DOXYGEN "Build Doxygen Documentation" OFF) -IF(BUILD_DOXYGEN) - FIND_PACKAGE(Doxygen) - ADD_SUBDIRECTORY(Doxygen) -ENDIF(BUILD_DOXYGEN) -#========================================================= - -#========================================================= -# Building in the source tree is forbidden -IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR}) - MESSAGE(FATAL_ERROR "Building in the source tree is not allowed ! Quit; remove the file 'CMakeCache.txt' and the folder 'CMakeFiles' an -d build outside the sources (for example 'mkdir build ; cmake '.") -ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR}) -#========================================================= - -#========================================================= -# Remove some MS Visual c++ flags -IF(MSVC) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) -ENDIF(MSVC) -#========================================================= - -#========================================================= -INCLUDE_DIRECTORIES(itk filters segmentation registration tools ${PROJECT_BINARY_DIR}) - # Select what is compiled ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(tools) ADD_SUBDIRECTORY(segmentation) ADD_SUBDIRECTORY(registration) - - -# Compilation options -OPTION(CLITK_EXPERIMENTAL "Enable experimental software and features" OFF) -OPTION(CLITK_BUILD_TOOLS "Build command-line tools" OFF) -OPTION(CLITK_BUILD_SEGMENTATION "Build command-line segmentation tools" OFF) -OPTION(CLITK_BUILD_REGISTRATION "Build command-line registration tools" OFF) - -OPTION(CLITK_BUILD_VV "Build vv the 4D visualizer (requires VTK and QT)" ON) -IF (CLITK_BUILD_VV) - ADD_SUBDIRECTORY(vv) -ENDIF(CLITK_BUILD_VV) - - -#========================================================= -# Build test when vv has been compiled -IF(BUILD_TESTING) - ADD_SUBDIRECTORY(tests) -ENDIF(BUILD_TESTING) - -#========================================================= -# Install scripts when running make install -SET(SCRIPTS - scripts/calculate_motion_amplitude.sh - scripts/midp_common.sh - scripts/registration.sh - scripts/create_midP.sh - scripts/create_midP-2.0.sh - scripts/create_mhd_4D.sh - scripts/create_mhd_4D_pattern.sh - scripts/create_midP_masks.sh - scripts/create_midP_masks-2.0.sh - scripts/pts_to_landmarks.sh - scripts/create_mhd_3D.sh - scripts/dicom_info.sh -) - -INSTALL (FILES ${SCRIPTS} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) - diff --git a/Doxygen/CMakeLists.txt b/Doxygen/CMakeLists.txt index f8f745c..6c57945 100644 --- a/Doxygen/CMakeLists.txt +++ b/Doxygen/CMakeLists.txt @@ -8,10 +8,10 @@ IF (BUILD_DOXYGEN) # # Configure the script and the doxyfile, then add target # - CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/Doxygen/doxygen.config.in + CONFIGURE_FILE(${CLITK_SOURCE_DIR}/Doxygen/doxygen.config.in ${PROJECT_BINARY_DIR}/Doxygen/doxygen.config) - CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/Doxygen/itkdoxygen.pl.in + CONFIGURE_FILE(${CLITK_SOURCE_DIR}/Doxygen/itkdoxygen.pl.in ${PROJECT_BINARY_DIR}/Doxygen/itkdoxygen.pl) ADD_CUSTOM_TARGET(Documentation diff --git a/cmake/build_opt.cmake b/cmake/build_opt.cmake new file mode 100644 index 0000000..a8f10ee --- /dev/null +++ b/cmake/build_opt.cmake @@ -0,0 +1,54 @@ +#========================================================= +#Support for the CTest dashboard testing system +OPTION(BUILD_TESTING "Build the testing tree" OFF) +IF (BUILD_TESTING) + OPTION(CLITK_BUILD_TESTING "Test ITK" ON) + INCLUDE(CTest) +ENDIF(BUILD_TESTING) +#========================================================= + + +#========================================================= +# If the user choose to build documentation, then search for Doxygen executables. +OPTION(BUILD_DOXYGEN "Build Doxygen Documentation" OFF) +IF(BUILD_DOXYGEN) + FIND_PACKAGE(Doxygen) + ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/Doxygen ${PROJECT_BINARY_DIR}/Doxygen) +ENDIF(BUILD_DOXYGEN) +#========================================================= + +# Compilation options +OPTION(CLITK_EXPERIMENTAL "Enable experimental software and features" OFF) +OPTION(CLITK_BUILD_TOOLS "Build command-line tools" OFF) +OPTION(CLITK_BUILD_SEGMENTATION "Build command-line segmentation tools" OFF) +OPTION(CLITK_BUILD_REGISTRATION "Build command-line registration tools" OFF) + +OPTION(CLITK_BUILD_VV "Build vv the 4D visualizer (requires VTK and QT)" ON) +IF (CLITK_BUILD_VV) + ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/vv ${PROJECT_BINARY_DIR}/vv) +ENDIF(CLITK_BUILD_VV) + +#========================================================= +# Build test when vv has been compiled +IF(BUILD_TESTING) + ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests) +ENDIF(BUILD_TESTING) + +#========================================================= +# Install scripts when running make install +SET(SCRIPTS + ${CLITK_SOURCE_DIR}/scripts/calculate_motion_amplitude.sh + ${CLITK_SOURCE_DIR}/scripts/midp_common.sh + ${CLITK_SOURCE_DIR}/scripts/registration.sh + ${CLITK_SOURCE_DIR}/scripts/create_midP.sh + ${CLITK_SOURCE_DIR}/scripts/create_midP-2.0.sh + ${CLITK_SOURCE_DIR}/scripts/create_mhd_4D.sh + ${CLITK_SOURCE_DIR}/scripts/create_mhd_4D_pattern.sh + ${CLITK_SOURCE_DIR}/scripts/create_midP_masks.sh + ${CLITK_SOURCE_DIR}/scripts/create_midP_masks-2.0.sh + ${CLITK_SOURCE_DIR}/scripts/pts_to_landmarks.sh + ${CLITK_SOURCE_DIR}/scripts/create_mhd_3D.sh + ${CLITK_SOURCE_DIR}/scripts/dicom_info.sh +) + +INSTALL (FILES ${SCRIPTS} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) diff --git a/cmake/common.cmake b/cmake/common.cmake index 3239e96..771467b 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -4,19 +4,39 @@ MACRO (DD in) ENDMACRO(DD) #========================================================= - #========================================================= #Set a reasonable build mode default if the user hasn't set any if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif (NOT CMAKE_BUILD_TYPE) + #========================================================= +INCLUDE_DIRECTORIES(${CLITK_SOURCE_DIR}/itk + ${CLITK_SOURCE_DIR}/filters + ${CLITK_SOURCE_DIR}/segmentation + ${CLITK_SOURCE_DIR}/registration + ${CLITK_SOURCE_DIR}/tools + ${CLITK_SOURCE_DIR}/common + ${PROJECT_BINARY_DIR}) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lib) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/common) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/tools) INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/tools) #For _ggo.h includes from other directories INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/segmentation) #For _ggo.h includes from other directories INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/registration) #For _ggo.h includes from other directories #========================================================= + +#========================================================= +# Building in the source tree is forbidden +IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR}) + MESSAGE(FATAL_ERROR "Building in the source tree is not allowed ! Quit; remove the file 'CMakeCache.txt' and the folder 'CMakeFiles' an +d build outside the sources (for example 'mkdir build ; cmake '.") +ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR}) +#========================================================= + +#========================================================= +# Remove some MS Visual c++ flags +IF(MSVC) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) +ENDIF(MSVC) +#========================================================= diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake new file mode 100644 index 0000000..225ddcc --- /dev/null +++ b/cmake/dependencies.cmake @@ -0,0 +1,36 @@ +#========================================================= +# Find ITK (required) +FIND_PACKAGE(ITK) +IF(ITK_FOUND) + INCLUDE("${ITK_USE_FILE}") +ELSE(ITK_FOUND) + MESSAGE(FATAL_ERROR "Cannot build without ITK. Please set ITK_DIR.") +ENDIF(ITK_FOUND) +#========================================================= + +#========================================================= +# Find VTK (required) +FIND_PACKAGE(VTK REQUIRED) +IF(VTK_FOUND) + INCLUDE("${VTK_USE_FILE}") +ELSE(VTK_FOUND) + MESSAGE(FATAL_ERROR "Please set VTK_DIR.") +ENDIF(VTK_FOUND) +#========================================================= + +#========================================================= +# Find gengetopt, will create a target exe if not found +SET(CMAKE_MODULE_PATH "${CLITK_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +FIND_PACKAGE(Gengetopt) +#========================================================= + +#========================================================= +# Find libstatgrab is installed, add clitkMemoryUsage.cxx in the library +FIND_LIBRARY(LIBSTATGRAB NAMES statgrab PATHS) +IF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") +# MESSAGE("Install libstatgrab (http://www.i-scream.org/libstatgrab/) for memory usage information") + SET(CLITK_MEMORY_INFO OFF) +ELSE (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") + SET(CLITK_MEMORY_INFO ON) +ENDIF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") +#========================================================= diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 6026b72..b956dd9 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,5 +1,5 @@ #========================================================= -INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake) +INCLUDE(${CLITK_SOURCE_DIR}/cmake/common.cmake) #========================================================= #========================================================= diff --git a/registration/CMakeLists.txt b/registration/CMakeLists.txt index 39ebae8..3ae919f 100644 --- a/registration/CMakeLists.txt +++ b/registration/CMakeLists.txt @@ -1,7 +1,7 @@ #ADD_LIBRARY(clitkLBGSB STATIC clitkLBGSBOptimizer.cxx) #========================================================= -INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake) +INCLUDE(${CLITK_SOURCE_DIR}/cmake/common.cmake) #========================================================= diff --git a/segmentation/CMakeLists.txt b/segmentation/CMakeLists.txt index 0cc7e2b..058b2c7 100644 --- a/segmentation/CMakeLists.txt +++ b/segmentation/CMakeLists.txt @@ -1,6 +1,6 @@ #========================================================= -INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake) +INCLUDE(${CLITK_SOURCE_DIR}/cmake/common.cmake) #========================================================= diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index e71e782..21a8101 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,5 +1,5 @@ #========================================================= -INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake) +INCLUDE(${CLITK_SOURCE_DIR}/cmake/common.cmake) #========================================================= # Add Libraries used in vv and clitk to avoid recompilation