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

COMP: ELASTIX-1 Add Windows support for GoogleTest

parent 00d22904
No related branches found
No related tags found
No related merge requests found
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()
......@@ -6,4 +6,4 @@ 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
endforeach()
......@@ -13,20 +13,20 @@ 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()
# Do not build tests by default since this requires GoogleTest submodule
# to be initialized. This saves users that just clone and build from
# seeing FATAL_ERRORs out of the box.
option( ELASTIX_BUILD_TESTING "Enable building tests." OFF )
if( ELASTIX_BUILD_TESTING )
enable_testing()
mark_as_advanced( BUILD_CTESTS )
option( BUILD_CTESTS "Enable CTests." ON )
if( BUILD_CTESTS )
add_subdirectory( Testing )
mark_as_advanced( ELASTIX_BUILD_CTESTS )
option( ELASTIX_BUILD_CTESTS "Enable CTests." ON )
if( ELASTIX_BUILD_CTESTS )
include( CTest )
endif()
add_subdirectory( Testing )
endif()
#---------------------------------------------------------------------
......@@ -35,9 +35,9 @@ endif()
#---------------------------------------------------------------------
# Build Documentation
mark_as_advanced( BUILD_DOXYGEN )
mark_as_advanced( ELASTIX_BUILD_DOXYGEN )
option( BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( BUILD_READTHEDOCS OFF )
mark_as_advanced( ELASTIX_BUILD_READTHEDOCS )
option( BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
cmake_minimum_required( VERSION 2.8 )
#---------------------------------------------------------------------
# Prerequisites
project( elastixSuperBuild )
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
......@@ -28,7 +25,9 @@ endif()
# 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
# Do not build tests by default since this requires GoogleTest submodule
# to be initialized. This saves users that just clone and build from
# seeing FATAL_ERRORs out of the box.
option( ELASTIX_BUILD_TESTING "Enable building tests." OFF )
if( ELASTIX_BUILD_TESTING )
......
......@@ -7,8 +7,8 @@ ExternalProject_Add( ${proj}
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS
--no-warn-unused-cli
-DBUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DBUILD_CTESTS:BOOL=${ELASTIX_BUILD_CTESTS}
-DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DELASTIX_BUILD_CTESTS:BOOL=${ELASTIX_BUILD_CTESTS}
-DITK_DIR:PATH=${ITK_DIR}
DEPENDS ${ELASTIX_DEPENDENCIES}
INSTALL_COMMAND ""
......
#---------------------------------------------------------------------
# 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(
......@@ -25,6 +34,6 @@ set( ElastixUnitTestSource
foreach( ElastixUnitTestFilename ${ElastixUnitTestSource} )
string( REPLACE ".cxx" "" ElastixUnitTestExe ${ElastixUnitTestFilename} )
add_executable( ${ElastixUnitTestExe} ${ElastixUnitTestFilename} )
target_link_libraries( ${ElastixUnitTestExe} ${TEST_LIBRARIES} )
target_link_libraries( ${ElastixUnitTestExe} ${ELASTIX_LIBRARIES} ${TEST_LIBRARIES} )
add_test( ElastixUnitTests ${ElastixUnitTestExe} )
endforeach()
\ 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