Skip to content
Snippets Groups Projects
Commit 00d22904 authored by Kasper Marstal's avatar Kasper Marstal
Browse files

COMP: ELASTIX-1 Add SuperBuild

parent 551c352c
No related branches found
No related tags found
No related merge requests found
[submodule "Testing/GoogleTest"]
path = Testing/GoogleTest
url = https://github.com/kaspermarstal/GoogleTest
tag = release-1.7.0
list( APPEND ElastixRequiredITKModules
ITKReview
)
foreach( ITKModule ${ElastixRequiredITKModules} )
if( NOT ${ITKModule}_LOADED )
message( FATAL_ERROR "Elastix requires that ITK is build with ${ITKModule}. Please rebuild ITK with Module_${ITKModule} set to ON." )
endif()
endforeach()
\ No newline at end of file
cmake_minimum_required( VERSION 2.8 )
#---------------------------------------------------------------------
project( elastix )
#---------------------------------------------------------------------
# ITK
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )
include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxRequiredITKModules.cmake" )
#---------------------------------------------------------------------
# Testing
if( BUILD_TESTING )
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/Testing/GoogleTest/.git" )
message( FATAL_ERROR "Could not find GoogleTest submodule. Please run git submodule init to compile tests." )
endif()
enable_testing()
mark_as_advanced( BUILD_CTESTS )
option( BUILD_CTESTS "Enable CTests." ON )
if( BUILD_CTESTS )
include( CTest )
endif()
add_subdirectory( Testing )
endif()
#---------------------------------------------------------------------
# Build Elastix
#---------------------------------------------------------------------
# Build Documentation
mark_as_advanced( BUILD_DOXYGEN )
option( BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( BUILD_READTHEDOCS OFF )
option( BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
cmake_minimum_required( VERSION 2.8 )
#---------------------------------------------------------------------
# Prerequisites
find_package( Git REQUIRED )
include( ExternalProject )
enable_language(C)
enable_language(CXX)
set( CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../CMake
${CMAKE_MODULE_PATH}
)
#---------------------------------------------------------------------
# Elastix SuperBuild configuration
# Build release by default
if( NOT DEFINED CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE "Release" )
endif()
# Build examples by default
# Examples will be build as an external project to verify the installation of elastix
option( ELASTIX_BUILD_EXAMPLES "Enable building examples." ON )
# Do not build testing by default since this requires GoogleTest submodule to be initialized
option( ELASTIX_BUILD_TESTING "Enable building tests." OFF )
if( ELASTIX_BUILD_TESTING )
mark_as_advanced( ELASTIX_BUILD_CTESTS )
option( ELASTIX_BUILD_CTESTS "Enable CTests." OFF )
endif()
#---------------------------------------------------------------------
# Build ITK as external project
set( ITK_VERSION_MAJOR "4" )
set( ITK_VERSION_MINOR "7" )
set( ITK_VERSION_PATCH "1" )
set( ITK_VERSION_STRING "${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}" )
mark_as_advanced( USE_SYSTEM_ITK )
option( USE_SYSTEM_ITK "Use an installed version of ITK" OFF )
if( USE_SYSTEM_ITK )
find_package( ITK ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR} REQUIRED )
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CMake/elxRequiredITKModules.cmake" )
else()
include( ExternalITK )
list( APPEND ELASTIX_DEPENDENCIES ITK )
endif()
#---------------------------------------------------------------------
# Build Elastix as an external project
include( Elastix )
set( proj Elastix )
ExternalProject_Add( ${proj}
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..
BINARY_DIR ${proj}-build
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS
--no-warn-unused-cli
-DBUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DBUILD_CTESTS:BOOL=${ELASTIX_BUILD_CTESTS}
-DITK_DIR:PATH=${ITK_DIR}
DEPENDS ${ELASTIX_DEPENDENCIES}
INSTALL_COMMAND ""
)
\ No newline at end of file
set( proj ITK )
set( ITK_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git )
set( ITK_TAG "v${ITK_VERSION_STRING}")
ExternalProject_Add( ${proj}
GIT_REPOSITORY ${ITK_REPOSITORY}
GIT_TAG ${ITK_TAG}
UPDATE_COMMAND ""
SOURCE_DIR ${proj}
BINARY_DIR ${proj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON
-DModule_ITKReview:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_SKIP_RPATH:BOOL=ON
-DITK_LEGACY_REMOVE:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
ExternalProject_Get_Property( ITK install_dir )
set( ITK_DIR "${install_dir}/lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" )
\ No newline at end of file
#---------------------------------------------------------------------
# Setup GoogleTest
add_subdirectory( GoogleTest )
include_directories(
${gtest_SOURCE_DIR}/include
)
set( TEST_LIBRARIES
gtest_main
)
#---------------------------------------------------------------------
# To add a test to the build system, append it to the list below.
# Any GoogleTests in these files are automatically added to CTest.
set( ElastixUnitTestSource
elxExampleTest.cxx
)
#---------------------------------------------------------------------
# Build test executables
foreach( ElastixUnitTestFilename ${ElastixUnitTestSource} )
string( REPLACE ".cxx" "" ElastixUnitTestExe ${ElastixUnitTestFilename} )
add_executable( ${ElastixUnitTestExe} ${ElastixUnitTestFilename} )
target_link_libraries( ${ElastixUnitTestExe} ${TEST_LIBRARIES} )
add_test( ElastixUnitTests ${ElastixUnitTestExe} )
endforeach()
\ No newline at end of file
#include "gtest/gtest.h"
TEST( ExampleGoogleTest, Assert ) {
ASSERT_TRUE( true );
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment