Newer
Older
# ---------------------------------------------------------------------
Kasper Marstal
committed
# To add a test to the build system, append it to the list below.
# Any GoogleTests in these files are automatically added to CTest and
Kasper Marstal
committed
set( ElastixUnitTestFilenames
elxBlueprintTest.cxx
elxElastixFilterTest.cxx
elxComponentFactoryTest.cxx
elxComponentInterfaceTest.cxx
elxOverlordTest.cxx
elxitkImageFilterTest.cxx
Kasper Marstal
committed
Kasper Marstal
committed
# ---------------------------------------------------------------------
# Options
if( SUPERELASTIX_BUILD_LONG_TESTS )
add_definitions( -DSUPERELASTIX_BUILD_LONG_TESTS )
Kasper Marstal
committed
endif()
Kasper Marstal
committed
# ---------------------------------------------------------------------
# Set data directories
set( SUPERELASTIX_UNITTEST_INPUT_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Input )
set( SUPERELASTIX_UNITTEST_OUTPUT_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Output )
set( SUPERELASTIX_UNITTEST_BASELINE_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Baseline )
Kasper Marstal
committed
if( NOT EXISTS ${SUPERELASTIX_UNITTEST_OUTPUT_DATA_DIR} )
file( MAKE_DIRECTORY ${SUPERELASTIX_UNITTEST_OUTPUT_DATA_DIR} )
if( NOT EXISTS ${SUPERELASTIX_UNITTEST_OUTPUT_DATA_DIR} )
message( FATAL_ERROR
"Could not create directory for output data. Make sure elastix has permission to write to disk."
)
endif()
# ---------------------------------------------------------------------
# Build test data manager
${CMAKE_CURRENT_SOURCE_DIR}/elxDataDirectories.h.in
${CMAKE_CURRENT_BINARY_DIR}/elxDataDirectories.h
Kasper Marstal
committed
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
add_library( DataManager elxDataManager.cxx )
list( APPEND TEST_LIBRARIES
DataManager
)
# ---------------------------------------------------------------------
# Build tests
message( STATUS "ITK_LIBRARIES: ${ITK_LIBRARIES}" )
foreach( ElastixUnitTestFilename ${ElastixUnitTestFilenames} )
# Build tests executables
Kasper Marstal
committed
string( REPLACE ".cxx" "" ElastixUnitTest ${ElastixUnitTestFilename} )
add_executable( ${ElastixUnitTest} ${ElastixUnitTestFilename} )
target_link_libraries( "${ElastixUnitTest}" ${SUPERELASTIX_LIBRARIES} ${ITK_LIBRARIES} ${TEST_LIBRARIES} )
Kasper Marstal
committed
# Add GoogleTest to CTest
GTEST_ADD_TESTS( ${ElastixUnitTest} "--gtest_output=xml:${CMAKE_BINARY_DIR}/Testing/Unit/${ElastixUnitTest}.xml" ${ElastixUnitTestFilename} )