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

COMP: ELASTIX-1 Add support for downloading test data at build time

parent d4e40280
No related branches found
No related tags found
No related merge requests found
......@@ -10,34 +10,29 @@ 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. This saves users that just clone and build from
# seeing FATAL_ERRORs out of the box.
# 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 )
mark_as_advanced( ELASTIX_BUILD_CTESTS )
option( ELASTIX_BUILD_CTESTS "Enable CTests." ON )
if( ELASTIX_BUILD_CTESTS )
include( CTest )
endif()
endif()
#---------------------------------------------------------------------
# Build Elastix
#---------------------------------------------------------------------
# Build Documentation
mark_as_advanced( ELASTIX_BUILD_DOXYGEN )
option( BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
option( ELASTIX_BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( ELASTIX_BUILD_READTHEDOCS )
option( BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
option( ELASTX_BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
......@@ -25,10 +25,8 @@ 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 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 )
# Build tests by default
option( ELASTIX_BUILD_TESTING "Enable building tests." ON )
if( ELASTIX_BUILD_TESTING )
mark_as_advanced( ELASTIX_BUILD_CTESTS )
......
......@@ -6,7 +6,7 @@ if( NOT EXISTS "${CMAKE_SOURCE_DIR}/Testing/GoogleTest/.git" )
git submodule update --init in the source directory to compile tests." )
endif()
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" )
include( ${CMAKE_SOURCE_DIR}/CMake/elxGoogleTestWinConfig.cmake )
endif()
......@@ -28,12 +28,40 @@ 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" "" ElastixUnitTestExe ${ElastixUnitTestFilename} )
add_executable( ${ElastixUnitTestExe} ${ElastixUnitTestFilename} )
target_link_libraries( ${ElastixUnitTestExe} ${ELASTIX_LIBRARIES} ${TEST_LIBRARIES} )
add_test( ElastixUnitTests ${ElastixUnitTestExe} )
endforeach()
\ No newline at end of file
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
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "gtest/gtest.h"
TEST( ExampleGoogleTest, Assert ) {
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