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 TestDicomDirElement.cxx
25 # add tests that require data
27 SET(TEST_SOURCES ${TEST_SOURCES}
30 TestPrintAllDocument.cxx # includes generated gdcmDataImages.h
31 #TestAllEntryVerify.cxx # includes generated gdcmDataImages.h
32 TestAllReadCompareDicom.cxx # includes generated gdcmDataImages.h
33 TestReadWriteReadCompare.cxx # includes generated gdcmDataImages.h
34 #TestCopyDicom.cxx # includes generated gdcmDataImages.h
35 # TestCopyRescaleDicom.cxx # includes generated gdcmDataImages.h
39 TestDicomDir.cxx # require DICOMDIR
40 TestBuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
41 TestMakeDicomDir.cxx # writes a file named "NewDICOMDIR"
42 TestSerieHelper.cxx # uses gdcmData as a default root directory
44 # add test that require VTK:
46 IF("${VTK_MAJOR_VERSION}" LESS 4)
47 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
48 ELSE("${VTK_MAJOR_VERSION}" LESS 4)
49 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
50 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
51 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
52 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
53 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
54 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
55 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
56 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
57 # Include the VTK library since we know this is going to work
58 INCLUDE(${VTK_USE_FILE})
61 ${GDCM_SOURCE_DIR}/vtk/
63 SET(TEST_SOURCES ${TEST_SOURCES}
69 ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
71 ENDIF (GDCM_DATA_ROOT)
77 ${GDCM_SOURCE_DIR}/src/
81 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
82 ADD_EXECUTABLE(gdcmTests ${Tests})
84 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
86 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
89 SET (TestsToRun ${Tests})
90 REMOVE (TestsToRun gdcmTests.cxx)
92 # Loop over files and create executables
93 FOREACH(file ${TEST_SOURCES})
94 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
95 ADD_TEST(${name} ${GDCM_TESTS} ${name})
96 ENDFOREACH(file ${TEST_SOURCES})
98 #-----------------------------------------------------------------------------
100 # We need to test the reading of all dicom images in the gdcmData directory
101 # First parse this directory and extract all images
103 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
104 FILE(GLOB GDCM_DATA_IMAGES_GLOB
105 "${GDCM_DATA_ROOT}/*.acr"
106 "${GDCM_DATA_ROOT}/*.dcm"
107 "${GDCM_DATA_ROOT}/*.nema"
108 "${GDCM_DATA_ROOT}/*.ima"
110 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB
111 "${GDCM_DATA_ROOT}/*FileSeq0.acr"
112 "${GDCM_DATA_ROOT}/*FileSeq0.dcm"
113 "${GDCM_DATA_ROOT}/*FileSeq0.nema"
114 "${GDCM_DATA_ROOT}/*FileSeq0.ima"
116 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
117 # Since there is a bug in cmake 1.8.3, I'll have to do two separate globs
118 FILE(GLOB GDCM_DATA_IMAGES_GLOB_ACR
119 "${GDCM_DATA_ROOT}/*.acr"
121 FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
122 "${GDCM_DATA_ROOT}/*.dcm"
124 FILE(GLOB GDCM_DATA_IMAGES_GLOB_NEMA
125 "${GDCM_DATA_ROOT}/*.nema"
127 FILE(GLOB GDCM_DATA_IMAGES_GLOB_IMA
128 "${GDCM_DATA_ROOT}/*.ima"
130 SET(GDCM_DATA_IMAGES_GLOB
131 ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR}
132 ${GDCM_DATA_IMAGES_GLOB_NEMA} ${GDCM_DATA_IMAGES_GLOB_IMA})
134 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_ACR
135 "${GDCM_DATA_ROOT}/*FileSeq0.acr"
137 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_DCM
138 "${GDCM_DATA_ROOT}/*FileSeq0.dcm"
140 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_NEMA
141 "${GDCM_DATA_ROOT}/*FileSeq0.nema"
143 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_IMA
144 "${GDCM_DATA_ROOT}/*FileSeq0.ima"
146 SET(GDCM_DATA_SEQ_IMAGES_GLOB
147 ${GDCM_DATA_SEQ_IMAGES_GLOB_DCM} ${GDCM_DATA_SEQ_IMAGES_GLOB_ACR}
148 ${GDCM_DATA_SEQ_IMAGES_GLOB_NEMA} ${GDCM_DATA_SEQ_IMAGES_GLOB_IMA})
149 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
151 # Black list of images known to break lots of readers (efilm, xmedcon ...):
154 # Multiframe Papyrus format image
155 # Just to remember this format exists, and is gdcm::File compliant
156 # (NOT gdcm::FileHelper ...)
157 # any contribution is welcome
158 "PET-cardio-Multiframe-Papyrus.dcm"
159 # From David Clunie's Compresion Dataset
160 "D_CLUNIE_CT1_JLSN.dcm"
161 "D_CLUNIE_CT1_JLSL.dcm"
162 #Not a Dicom Image, but a RT Object
163 "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm"
165 "ETIAM_video_002.dcm"
166 #Something stupid occured in the code for LibIDO images.
167 #I Black list them for a while. JP
168 "gdcm-ACR-LibIDO.acr"
169 "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
170 #16 Bits per pixel images with LUT 16 Bits.
171 #I wait to be 100% sure before releasing them. JP
176 # Don't understand why jasper is segfaulting with borland...I bet a borland bug
180 "D_CLUNIE_CT1_J2KR.dcm"
181 "D_CLUNIE_CT1_J2KI.dcm"
185 # Add a special test that requires dciodvfy from dicom3tools
186 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
188 # This is a GLOB expression, change it into a list separated with a comma and \n
189 SET(GDCM_DATA_IMAGES)
190 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
191 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
193 ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
194 ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
195 ENDIF(DCIODVFY_FOUND)
196 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
198 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
202 SET(GDCM_DATA_SEQ_IMAGES)
203 FOREACH(filename ${GDCM_DATA_SEQ_IMAGES_GLOB})
204 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
205 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
207 STRING(REGEX REPLACE "(.*)FileSeq0(.*)" "\\1FileSeq%d\\2" filename_temp2 ${filename_temp})
209 SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp2}\",")
213 # Populate GDCM_DATA_IMAGES:
214 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
215 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"
218 # Populate GDCM_DATA_SEQ_IMAGES:
219 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
220 "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n"