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} ) ...@@ -6,4 +6,4 @@ foreach( ITKModule ${ElastixRequiredITKModules} )
if( NOT ${ITKModule}_LOADED ) if( NOT ${ITKModule}_LOADED )
message( FATAL_ERROR "Elastix requires that ITK is build with ${ITKModule}. Please rebuild ITK with Module_${ITKModule} set to ON." ) message( FATAL_ERROR "Elastix requires that ITK is build with ${ITKModule}. Please rebuild ITK with Module_${ITKModule} set to ON." )
endif() endif()
endforeach() endforeach()
\ No newline at end of file
...@@ -13,20 +13,20 @@ include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxRequiredITKModules.cmake" ) ...@@ -13,20 +13,20 @@ include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxRequiredITKModules.cmake" )
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Testing # Testing
if( BUILD_TESTING ) # Do not build tests by default since this requires GoogleTest submodule
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/Testing/GoogleTest/.git" ) # to be initialized. This saves users that just clone and build from
message( FATAL_ERROR "Could not find GoogleTest submodule. Please run git submodule init to compile tests." ) # seeing FATAL_ERRORs out of the box.
endif() option( ELASTIX_BUILD_TESTING "Enable building tests." OFF )
if( ELASTIX_BUILD_TESTING )
enable_testing() enable_testing()
add_subdirectory( Testing )
mark_as_advanced( BUILD_CTESTS )
option( BUILD_CTESTS "Enable CTests." ON ) mark_as_advanced( ELASTIX_BUILD_CTESTS )
if( BUILD_CTESTS ) option( ELASTIX_BUILD_CTESTS "Enable CTests." ON )
if( ELASTIX_BUILD_CTESTS )
include( CTest ) include( CTest )
endif() endif()
add_subdirectory( Testing )
endif() endif()
#--------------------------------------------------------------------- #---------------------------------------------------------------------
...@@ -35,9 +35,9 @@ endif() ...@@ -35,9 +35,9 @@ endif()
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Build Documentation # Build Documentation
mark_as_advanced( BUILD_DOXYGEN ) mark_as_advanced( ELASTIX_BUILD_DOXYGEN )
option( BUILD_DOXYGEN "Enable building Doxygen documentation." OFF ) 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 ) option( BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
cmake_minimum_required( VERSION 2.8 ) cmake_minimum_required( VERSION 2.8 )
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Prerequisites project( elastixSuperBuild )
find_package( Git REQUIRED ) find_package( Git REQUIRED )
include( ExternalProject ) include( ExternalProject )
enable_language(C)
enable_language(CXX)
set( CMAKE_MODULE_PATH set( CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../CMake ${CMAKE_CURRENT_SOURCE_DIR}/../CMake
...@@ -28,7 +25,9 @@ endif() ...@@ -28,7 +25,9 @@ endif()
# Examples will be build as an external project to verify the installation of elastix # Examples will be build as an external project to verify the installation of elastix
option( ELASTIX_BUILD_EXAMPLES "Enable building examples." ON ) 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 ) option( ELASTIX_BUILD_TESTING "Enable building tests." OFF )
if( ELASTIX_BUILD_TESTING ) if( ELASTIX_BUILD_TESTING )
......
...@@ -7,8 +7,8 @@ ExternalProject_Add( ${proj} ...@@ -7,8 +7,8 @@ ExternalProject_Add( ${proj}
INSTALL_DIR ${CMAKE_INSTALL_PREFIX} INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS CMAKE_ARGS
--no-warn-unused-cli --no-warn-unused-cli
-DBUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING} -DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DBUILD_CTESTS:BOOL=${ELASTIX_BUILD_CTESTS} -DELASTIX_BUILD_CTESTS:BOOL=${ELASTIX_BUILD_CTESTS}
-DITK_DIR:PATH=${ITK_DIR} -DITK_DIR:PATH=${ITK_DIR}
DEPENDS ${ELASTIX_DEPENDENCIES} DEPENDS ${ELASTIX_DEPENDENCIES}
INSTALL_COMMAND "" INSTALL_COMMAND ""
......
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Setup GoogleTest # 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 ) add_subdirectory( GoogleTest )
include_directories( include_directories(
...@@ -25,6 +34,6 @@ set( ElastixUnitTestSource ...@@ -25,6 +34,6 @@ set( ElastixUnitTestSource
foreach( ElastixUnitTestFilename ${ElastixUnitTestSource} ) foreach( ElastixUnitTestFilename ${ElastixUnitTestSource} )
string( REPLACE ".cxx" "" ElastixUnitTestExe ${ElastixUnitTestFilename} ) string( REPLACE ".cxx" "" ElastixUnitTestExe ${ElastixUnitTestFilename} )
add_executable( ${ElastixUnitTestExe} ${ElastixUnitTestFilename} ) add_executable( ${ElastixUnitTestExe} ${ElastixUnitTestFilename} )
target_link_libraries( ${ElastixUnitTestExe} ${TEST_LIBRARIES} ) target_link_libraries( ${ElastixUnitTestExe} ${ELASTIX_LIBRARIES} ${TEST_LIBRARIES} )
add_test( ElastixUnitTests ${ElastixUnitTestExe} ) add_test( ElastixUnitTests ${ElastixUnitTestExe} )
endforeach() 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