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
20 # add tests that require data
22 SET(TEST_SOURCES ${TEST_SOURCES}
23 TestReadWriteReadCompare.cxx # includes generated gdcmDataImages.h
24 PrintAllDocument.cxx # includes generated gdcmDataImages.h
25 TestAllReadCompareDicom.cxx # includes generated gdcmDataImages.h
26 TestAllEntryVerify.cxx # includes generated gdcmDataImages.h
29 TestCopyRescaleDicom.cxx
31 TestDicomDir.cxx # require DICOMDIR
32 BuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
33 makeDicomDir.cxx # writes a file named "NewDICOMDIR"
36 # add test that require VTK:
38 # Include the VTK library
39 INCLUDE(${VTK_USE_FILE})
42 ${GDCM_SOURCE_DIR}/vtk/
44 SET(TEST_SOURCES ${TEST_SOURCES}
50 ENDIF (GDCM_DATA_ROOT)
56 ${GDCM_SOURCE_DIR}/src/
60 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
61 ADD_EXECUTABLE(gdcmTests ${Tests})
63 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
65 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
68 SET (TestsToRun ${Tests})
69 REMOVE (TestsToRun gdcmTests.cxx)
71 # Loop over files and create executables
72 FOREACH(file ${TEST_SOURCES})
73 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
75 # ADD_TEST(${name} ${GDCM_TESTS} ${name}
76 # -D ${GDCM_DATA_ROOT}
77 # -T ${GDCM_BINARY_DIR}/Testing/Temporary
78 # -V Baseline/gdcm/${name}.png)
79 # ELSE (GDCM_DATA_ROOT)
80 ADD_TEST(${name} ${GDCM_TESTS} ${name})
81 # ENDIF (GDCM_DATA_ROOT)
82 ENDFOREACH(file ${TEST_SOURCES})
84 #-----------------------------------------------------------------------------
86 # We need to test the reading of all dicom images in the gdcmData directory
87 # First parse this directory and extract all images
89 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
90 FILE(GLOB GDCM_DATA_IMAGES_GLOB
91 "${GDCM_DATA_ROOT}/*.acr"
92 "${GDCM_DATA_ROOT}/*.dcm"
93 "${GDCM_DATA_ROOT}/*.nema"
94 "${GDCM_DATA_ROOT}/*.ima"
96 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB
97 "${GDCM_DATA_ROOT}/*FileSeq0.acr"
98 "${GDCM_DATA_ROOT}/*FileSeq0.dcm"
99 "${GDCM_DATA_ROOT}/*FileSeq0.nema"
100 "${GDCM_DATA_ROOT}/*FileSeq0.ima"
102 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
103 # Since there is a bug in cmake 1.8.3, I'll have to do two separate globs
104 FILE(GLOB GDCM_DATA_IMAGES_GLOB_ACR
105 "${GDCM_DATA_ROOT}/*.acr"
107 FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
108 "${GDCM_DATA_ROOT}/*.dcm"
110 FILE(GLOB GDCM_DATA_IMAGES_GLOB_NEMA
111 "${GDCM_DATA_ROOT}/*.nema"
113 FILE(GLOB GDCM_DATA_IMAGES_GLOB_IMA
114 "${GDCM_DATA_ROOT}/*.ima"
116 SET(GDCM_DATA_IMAGES_GLOB
117 ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR}
118 ${GDCM_DATA_IMAGES_GLOB_NEMA} ${GDCM_DATA_IMAGES_GLOB_IMA})
120 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_ACR
121 "${GDCM_DATA_ROOT}/*FileSeq0.acr"
123 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_DCM
124 "${GDCM_DATA_ROOT}/*FileSeq0.dcm"
126 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_NEMA
127 "${GDCM_DATA_ROOT}/*FileSeq0.nema"
129 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_IMA
130 "${GDCM_DATA_ROOT}/*FileSeq0.ima"
132 SET(GDCM_DATA_SEQ_IMAGES_GLOB
133 ${GDCM_DATA_SEQ_IMAGES_GLOB_DCM} ${GDCM_DATA_SEQ_IMAGES_GLOB_ACR}
134 ${GDCM_DATA_SEQ_IMAGES_GLOB_NEMA} ${GDCM_DATA_SEQ_IMAGES_GLOB_IMA})
135 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
137 # Black list of images known to break lots of readers (efilm, xmedcon ...):
139 # serial killer (also segfaults vtkgdcmViewer, but NOT PrintFile)
140 "gdcm-JPEG-LossLessThoravision.dcm"
142 # Mathieu: temporarily remove as it kills my gnome session (but not kde)
143 # JPR: also breaks TestReadWriteReadCompare : Pixel differ (as expanded
145 "KODAK-12-MONO1-Odd_Terminated_Sequence.dcm"
148 # This is a GLOB expression, change it into a list separated with a comma and \n
149 SET(GDCM_DATA_IMAGES)
150 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
151 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
152 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
154 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
158 SET(GDCM_DATA_SEQ_IMAGES)
159 FOREACH(filename ${GDCM_DATA_SEQ_IMAGES_GLOB})
160 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
161 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
163 STRING(REGEX REPLACE "(.*)FileSeq0(.*)" "\\1FileSeq%d\\2" filename_temp2 ${filename_temp})
165 SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp2}\",")
169 # Populate GDCM_DATA_IMAGES:
170 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
171 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"
174 # Populate GDCM_DATA_SEQ_IMAGES:
175 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
176 "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n"