Newer
Older
cmake_minimum_required( VERSION 3.0.2 )
# Explicitly add INCREMENTAL linking option to command lines.
# http://www.cmake.org/pipermail/cmake/2010-February/035174.html
Kasper Marstal
committed
#set( MSVC_INCREMENTAL_DEFAULT ON )
# ---------------------------------------------------------------------
enable_language(C)
enable_language(CXX)
Kasper Marstal
committed
set( CMAKE_CXX_STANDARD 11 )
# Place libraries and executables in the bin directory
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bin"
)
# Include SuperElastix CMake scripts
Kasper Marstal
committed
list( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" )
Kasper Marstal
committed
# -----------------------------------------------------------------
# Compiler-dependent settings
Kasper Marstal
committed
# GCC
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU )
add_definitions(
-DVCL_CAN_STATIC_CONST_INIT_FLOAT=0
-DVCL_CAN_STATIC_CONST_INIT_INT=0
)
endif()
# MSVC
Kasper Marstal
committed
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
Kasper Marstal
committed
string( LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"Source code directory path length is too long for MSVC (${n} > 50)."
"Please move the source code directory to a directory with a shorter path."
)
endif()
string( LENGTH "${CMAKE_CURRENT_BINARY_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"Build directory path length is too long for MSVC (${n} > 50)."
"Please move the build directory to a directory with a shorter path."
)
endif()
# ---------------------------------------------------------------------
# ITK
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )
include("${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxRequiredITKModules.cmake")
# ---------------------------------------------------------------------
# Boost Graph Library
include_directories( ${Boost_INCLUDE_DIRS} )
# ---------------------------------------------------------------------
# OpenMP Library
# Required for ElastixComponent
# gcc needs the appropriate flags to support OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# ---------------------------------------------------------------------
# For now we just enable all modules
Kasper Marstal
committed
include( elxModules )
elxmodule_enable( ModuleCore )
elxmodule_enable( ModuleElastix )
elxmodule_enable( ModuleExamples )
# TODO: Build tests depending on enabled modules
# ---------------------------------------------------------------------
# Testing
Kasper Marstal
committed
option( SUPERELASTIX_BUILD_TESTING "Enable building tests." ON )
if( ${SUPERELASTIX_BUILD_TESTING} )
mark_as_advanced( SUPERELASTIX_BUILD_LONG_TESTS )
option( SUPERELASTIX_BUILD_LONG_TESTS "Also build tests that take a long time to run." OFF )
add_subdirectory( Testing )
# ---------------------------------------------------------------------
mark_as_advanced( SUPERELASTIX_BUILD_DOXYGEN )
option( SUPERELASTIX_BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( SUPERELASTIX_BUILD_READTHEDOCS )
option( SUPERELASTIX_BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )