1 # CMakeLists for Testing purpose
2 # Cxx file that need a file to run should be place aproprietly
4 SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
6 SET(GDCM_TESTS ${CXX_TEST_PATH}/gdcmTests)
8 # add test that does not require data:
9 # They usally return if no argument is given
17 # add tests that require data
19 SET(TEST_SOURCES ${TEST_SOURCES}
20 PrintHeader.cxx #require test.acr
24 testDicomDir.cxx #require DICOMDIR
29 # add test that require VTK:
32 ${GDCM_SOURCE_DIR}/vtk/
34 SET(TEST_SOURCES ${TEST_SOURCES}
38 ENDIF (GDCM_DATA_ROOT)
44 ${GDCM_SOURCE_DIR}/src/
48 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
49 ADD_EXECUTABLE(gdcmTests ${Tests})
51 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
53 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
56 SET (TestsToRun ${Tests})
57 REMOVE (TestsToRun gdcmTests.cxx)
59 # Loop over files and create executables
60 FOREACH(file ${TEST_SOURCES})
61 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
63 # ADD_TEST(${name} ${CXX_TEST_PATH}/gdcmTests ${name}
64 # -D ${GDCM_DATA_ROOT}
65 # -T ${GDCM_BINARY_DIR}/Testing/Temporary
66 # -V Baseline/gdcm/${name}.png)
67 # ELSE (GDCM_DATA_ROOT)
68 ADD_TEST(${name} ${GDCM_TESTS} ${name})
69 # ENDIF (GDCM_DATA_ROOT)
70 ENDFOREACH(file ${TEST_SOURCES})
72 #-----------------------------------------------------------------------------
74 # We need to test the reading of all dicom images in the gdcmData directory
75 # First parse this directory and extract all images
77 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
78 FILE(GLOB GDCM_DATA_IMAGES_GLOB
79 "${GDCM_DATA_ROOT}/*.acr"
80 "${GDCM_DATA_ROOT}/*.dcm"
82 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
83 # Since there is a bug in cmake 1.8.3, I'll have to do two separate globs
84 FILE(GLOB GDCM_DATA_IMAGES_GLOB_ACR
85 "${GDCM_DATA_ROOT}/*.acr"
87 FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
88 "${GDCM_DATA_ROOT}/*.dcm"
90 SET(GDCM_DATA_IMAGES_GLOB ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR})
91 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
93 # Black list of images known to break lots of readers (efilm, xmedcon ...):
95 "gdcm-JPEG-LossLessThoravision.dcm"
98 # This is a GLOB expression, change it into a list separated with a comma and \n
100 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
101 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
102 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
104 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename}\",")
108 # Populate GDCM_DATA_IMAGES:
109 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
110 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"