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
23 TestDicomDirElement.cxx
26 TestBuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
29 SET(TEST_SOURCES ${TEST_SOURCES}
34 # add tests that require data
36 SET(TEST_SOURCES ${TEST_SOURCES}
39 TestLoadAllDocumentsNoPrivNoSeq.cxx # includes generated gdcmDataImages.h
40 #TestLoadAllDocumentsNoShadow.cxx # includes generated gdcmDataImages.h
41 TestPrintAllDocument.cxx # includes generated gdcmDataImages.h
42 #TestAllEntryVerify.cxx # includes generated gdcmDataImages.h
43 #TestAllReadCompareDicom.cxx # includes generated gdcmDataImages.h
44 TestReadWriteReadCompare.cxx # includes generated gdcmDataImages.h
45 TestReadWriteJPEGReadCompare.cxx # includes generated gdcmDataImages.h
46 TestReadWriteJPEG2000ReadCompare.cxx # includes generated gdcmDataImages.h
48 #TestCopyDicom.cxx # includes generated gdcmDataImages.h
49 # TestCopyRescaleDicom.cxx # includes generated gdcmDataImages.h
53 TestDicomDir.cxx # require DICOMDIR
55 TestMakeDicomDir.cxx # writes a file named "NewDICOMDIR"
56 TestSerieHelper.cxx # uses gdcmData as a default root directory
58 TestValidate.cxx #Just to have on overviews of oddities ...
60 # add test that require VTK:
62 IF("${VTK_MAJOR_VERSION}" LESS 4)
63 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
64 ELSE("${VTK_MAJOR_VERSION}" LESS 4)
65 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
66 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
67 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
68 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
69 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
70 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
71 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
72 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
73 # Include the VTK library since we know this is going to work
74 INCLUDE(${VTK_USE_FILE})
77 ${GDCM_SOURCE_DIR}/vtk
79 SET(TEST_SOURCES ${TEST_SOURCES}
85 ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
87 ENDIF (GDCM_DATA_ROOT)
93 ${GDCM_SOURCE_DIR}/src
97 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
98 ADD_EXECUTABLE(gdcmTests ${Tests})
101 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
103 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
104 ENDIF(GDCM_DATA_ROOT)
106 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
109 SET (TestsToRun ${Tests})
110 REMOVE (TestsToRun gdcmTests.cxx)
112 # Loop over files and create executables
113 FOREACH(file ${TEST_SOURCES})
114 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
115 ADD_TEST(${name} ${GDCM_TESTS} ${name})
116 ENDFOREACH(file ${TEST_SOURCES})
118 #-----------------------------------------------------------------------------
120 # We need to test the reading of all dicom images in the gdcmData directory
121 # First parse this directory and extract all images
123 FILE(GLOB GDCM_DATA_IMAGES_GLOB
124 "${GDCM_DATA_ROOT}/*.acr"
125 "${GDCM_DATA_ROOT}/*.dcm"
126 "${GDCM_DATA_ROOT}/*.nema"
127 "${GDCM_DATA_ROOT}/*.ima"
130 # Black list of images known to break lots of readers (efilm, xmedcon ...):
132 # Multiframe Papyrus format image
133 # Just to remember this format exists, and is gdcm::File compliant
134 # (NOT gdcm::FileHelper ...)
135 # any contribution is welcome
136 "PET-cardio-Multiframe-Papyrus.dcm"
137 # From David Clunie's Compresion Dataset
138 "D_CLUNIE_CT1_JLSN.dcm"
139 "D_CLUNIE_CT1_JLSL.dcm"
140 #Not a Dicom Image, but a RT Object
141 "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm"
143 "ETIAM_video_002.dcm"
144 #Something stupid occured in the code for LibIDO images.
145 #I Black list them for a while. JP
146 #"gdcm-ACR-LibIDO.acr"
147 "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
148 #16 Bits per pixel images with LUT 16 Bits.
149 #I wait to be 100% sure before releasing them. JP
152 # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
153 # but then it breaks other images...
154 "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
156 #RTDOSE, 32 bits image : cannot be compressed
162 #Still cause troubles (see the .README.txt file for more details)
163 "MR_Philips_Intera_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"
164 "MR_Philips_Intera_PrivateSequenceExplicitVR.dcm"
165 #The 2 previous images are identical !
166 #--> Replaced by more significant name
167 "MR_Philips_Intera_PrivateSequenceExplicitVR_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"
169 #hexedit shows something *very* strange around offset 0x76e !
170 #the images looks *over*corrupted (on disc, not from the manufacturer!)
171 "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
173 # Seems this one hangs on 64 bits processors ?!?
174 # I blacklist it untill the pb is solved.
175 # (to get some more green on the Dasboards)
176 "MR_Philips-Intera_BreaksNOSHADOW.dcm"
179 # Create a specific list of dicom files that we know are part of a sequence
181 "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
184 # Add a special test that requires dciodvfy from dicom3tools
185 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
187 # This is a GLOB expression, change it into a list separated with a comma and \n
188 SET(GDCM_DATA_IMAGES)
189 SET(GDCM_DATA_SEQ_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}\",")
199 # SEQ_LIST is a regular expression:
200 STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
202 SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
207 # Populate GDCM_DATA_IMAGES:
208 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
209 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"
212 # Populate GDCM_DATA_SEQ_IMAGES:
213 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
214 "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n"
217 #-----------------------------------------------------------------------------
218 # Trying to solve a bizarre problem when loading shared lib if gdcm is static
219 # Therefore I disable the test when building SHAREDLIBS
220 IF(UNIX AND NOT BUILD_SHARED_LIBS)
221 ADD_LIBRARY(dynmodule MODULE dynmodule.cxx)
222 TARGET_LINK_LIBRARIES(dynmodule gdcm)
223 ADD_EXECUTABLE(loadmodule loadmodule.cxx )
224 TARGET_LINK_LIBRARIES(loadmodule gdcm -ldl)
225 ADD_TEST(loadmodule ${CXX_TEST_PATH}/loadmodule)
226 ENDIF(UNIX AND NOT BUILD_SHARED_LIBS)
229 #-----------------------------------------------------------------------------
230 # Do the build against an installed gdcm
231 SET(GDCM_TEST_INSTALL_LEFT "${CMAKE_INSTALL_PREFIX}")
232 SET(GDCM_TEST_INSTALL_RIGHT "${GDCM_BINARY_DIR}/InstallTest/Root")
233 STRING(COMPARE EQUAL "${GDCM_TEST_INSTALL_LEFT}" "${GDCM_TEST_INSTALL_RIGHT}"
235 IF(GDCM_TEST_INSTALL)
237 ${CMAKE_CTEST_COMMAND}
238 # ${GDCM_INSTALL_TEST_CONFIG_TYPE}
239 --build-and-test ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
240 --build-generator ${CMAKE_GENERATOR}
242 --build-makeprogram ${CMAKE_MAKE_PROGRAM}
244 --build-target install)
245 ENDIF(GDCM_TEST_INSTALL)