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

Merge branch 'ELASTIX-1-setup-development-infrastructure' into develop

parents c9fda6a8 cab6dee7
No related branches found
No related tags found
No related merge requests found
.DS_Store
build
[submodule "Testing/GoogleTest"]
path = Testing/GoogleTest
url = https://github.com/kaspermarstal/GoogleTest
tag = release-1.7.0
language: cpp
compiler:
- clang
- gcc
before_install:
- pwd
- date -u
- uname -a
# Out-of-source build
- cd ..
- mkdir SuperElastix-build
- cd SuperElastix-build
before_script:
- export OMP_NUM_THREADS=2
- echo $OMP_NUM_THREADS
script:
- cmake ../SuperElastix/SuperBuild
- make --jobs=2 | grep -v '^--' | grep -v '^Installing'
- make test
set( CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
)
include( ${CMAKE_SOURCE_DIR}/CMake/elxCompilerFlags.cmake )
foreach( CompilerFlag ${CompilerFlags} )
# GoogleTest needs static linking
string( REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}" )
endforeach()
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()
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" )
#---------------------------------------------------------------------
# Build Elastix
#---------------------------------------------------------------------
# Testing
# Do not build tests by default since this requires GoogleTest submodule
# to be initialized. Otherwise users may see FATAL_ERRORs out of the box.
# The SuperBuild will correctly initialize the GoogleTest submodule and
# build tests by default.
option( ELASTIX_BUILD_TESTING "Enable building tests." OFF )
if( ELASTIX_BUILD_TESTING )
enable_testing()
add_subdirectory( Testing )
endif()
#---------------------------------------------------------------------
# Build Documentation
mark_as_advanced( ELASTIX_BUILD_DOXYGEN )
option( ELASTIX_BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( ELASTIX_BUILD_READTHEDOCS )
option( ELASTX_BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
cmake_minimum_required( VERSION 2.8 )
#---------------------------------------------------------------------
project( elastixSuperBuild )
find_package( Git REQUIRED )
include( ExternalProject )
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 )
# Build tests by default
option( ELASTIX_BUILD_TESTING "Enable building tests." ON )
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
-DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DELASTIX_BUILD_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
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/Testing/GoogleTest/.git" )
message( FATAL_ERROR "Could not find GoogleTest submodule. Please run
git submodule update --init in the source directory to compile tests." )
endif()
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" )
include( ${CMAKE_SOURCE_DIR}/CMake/elxGoogleTestWinConfig.cmake )
endif()
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
)
#---------------------------------------------------------------------
# Setup ExternalData
# ExternalData module was introduced in CMake version 2.8.11
cmake_minimum_required( VERSION 2.8.11 )
include( ExternalData )
list( APPEND ExternalData_URL_TEMPLATES
"http://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=%(hash)&algorithm=%(algo)"
"https://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=%(hash)&algorithm=%(algo)"
)
#---------------------------------------------------------------------
# To add data to a tests, create a list "${filename}Data" (without
# the filename extension) and add data to this list.
set( elxExampleTestData
DATA{Data/Input/BrainProtonDensitySliceR10X13Y17.png}
)
#---------------------------------------------------------------------
# Build test executables
foreach( ElastixUnitTestFilename ${ElastixUnitTestSource} )
string( REPLACE ".cxx" "" ElastixUnitTest ${ElastixUnitTestFilename} )
add_executable( ${ElastixUnitTest} ${ElastixUnitTestFilename} )
target_link_libraries( ${ElastixUnitTest} ${ELASTIX_LIBRARIES} ${ITK_LIBRARIES} ${TEST_LIBRARIES} )
ExternalData_Add_Test( "${ElastixUnitTest}ExternalDataTarget"
NAME ${ElastixUnitTest}
COMMAND ${ElastixUnitTest} ${${ElastixUnitTest}Data}
)
ExternalData_Add_Target( "${ElastixUnitTest}ExternalDataTarget"} )
endforeach()
610392a128986d934dfc0a1b0dc27e91
\ No newline at end of file
Subproject commit 7c508e6611f14cbc0da048c0e726870b93b1cc00
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "gtest/gtest.h"
TEST( GoogleTest, GoogleTest ) {
/**
* This example demonstrates the GoogleTest framework.
*
* When the test is built, the ExternalData CMake module
* scans the Testing/Data directory for content links on
* the form "[filename].[ext].md5" (text files with hashes).
* The content links are replaced with files from the file
* repository and checked for hash consistensy.
*/
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