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
22 TestDicomDirElement.cxx
28 SET(TEST_SOURCES ${TEST_SOURCES}
33 # add tests that require data
35 SET(TEST_SOURCES ${TEST_SOURCES}
38 TestLoadAllDocumentsNoPrivNoSeq.cxx # includes generated gdcmDataImages.h
39 TestPrintAllDocument.cxx # includes generated gdcmDataImages.h
40 #TestAllEntryVerify.cxx # includes generated gdcmDataImages.h
41 TestAllReadCompareDicom.cxx # includes generated gdcmDataImages.h
42 TestReadWriteReadCompare.cxx # includes generated gdcmDataImages.h
43 #TestCopyDicom.cxx # includes generated gdcmDataImages.h
44 # TestCopyRescaleDicom.cxx # includes generated gdcmDataImages.h
48 TestDicomDir.cxx # require DICOMDIR
49 TestBuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
50 TestMakeDicomDir.cxx # writes a file named "NewDICOMDIR"
51 TestSerieHelper.cxx # uses gdcmData as a default root directory
53 TestValidate.cxx #Just to have on overviews of oddities ...
55 # add test that require VTK:
57 IF("${VTK_MAJOR_VERSION}" LESS 4)
58 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
59 ELSE("${VTK_MAJOR_VERSION}" LESS 4)
60 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
61 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
62 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
63 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
64 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
65 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
66 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
67 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
68 # Include the VTK library since we know this is going to work
69 INCLUDE(${VTK_USE_FILE})
72 ${GDCM_SOURCE_DIR}/vtk
74 SET(TEST_SOURCES ${TEST_SOURCES}
80 ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
82 ENDIF (GDCM_DATA_ROOT)
88 ${GDCM_SOURCE_DIR}/src
92 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
93 ADD_EXECUTABLE(gdcmTests ${Tests})
95 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
97 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
100 SET (TestsToRun ${Tests})
101 REMOVE (TestsToRun gdcmTests.cxx)
103 # Loop over files and create executables
104 FOREACH(file ${TEST_SOURCES})
105 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
106 ADD_TEST(${name} ${GDCM_TESTS} ${name})
107 ENDFOREACH(file ${TEST_SOURCES})
109 #-----------------------------------------------------------------------------
111 # We need to test the reading of all dicom images in the gdcmData directory
112 # First parse this directory and extract all images
114 FILE(GLOB GDCM_DATA_IMAGES_GLOB
115 "${GDCM_DATA_ROOT}/*.acr"
116 "${GDCM_DATA_ROOT}/*.dcm"
117 "${GDCM_DATA_ROOT}/*.nema"
118 "${GDCM_DATA_ROOT}/*.ima"
121 # Black list of images known to break lots of readers (efilm, xmedcon ...):
123 # Multiframe Papyrus format image
124 # Just to remember this format exists, and is gdcm::File compliant
125 # (NOT gdcm::FileHelper ...)
126 # any contribution is welcome
127 "PET-cardio-Multiframe-Papyrus.dcm"
128 # From David Clunie's Compresion Dataset
129 "D_CLUNIE_CT1_JLSN.dcm"
130 "D_CLUNIE_CT1_JLSL.dcm"
131 #Not a Dicom Image, but a RT Object
132 "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm"
134 "ETIAM_video_002.dcm"
135 #Something stupid occured in the code for LibIDO images.
136 #I Black list them for a while. JP
137 #"gdcm-ACR-LibIDO.acr"
138 "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
139 #16 Bits per pixel images with LUT 16 Bits.
140 #I wait to be 100% sure before releasing them. JP
143 # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
144 # but then it breaks other images...
145 "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
149 # I probabely messed up smething with the .png, .tst of
150 # the images I recently added to the Test Suite
151 # I Black list them, until I find where is the pb.
152 #"US-RGB-8-esopecho.dcm"
153 #"MR_Philips_Intera_No_PrivateSequenceImplicitVR.dcm"
154 #"MR_SIEMENS_forceLoad29-1010_29-1020.dcm"
156 #Still cause troubles (see the .README.txt file for more details)
157 "MR_Philips_Intera_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"
158 "MR_Philips_Intera_PrivateSequenceExplicitVR.dcm"
159 "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
162 # Create a specific list of dicom files that we know are part of a sequence
164 "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
167 # Add a special test that requires dciodvfy from dicom3tools
168 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
170 # This is a GLOB expression, change it into a list separated with a comma and \n
171 SET(GDCM_DATA_IMAGES)
172 SET(GDCM_DATA_SEQ_IMAGES)
173 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
174 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
176 ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
177 ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
178 ENDIF(DCIODVFY_FOUND)
179 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
181 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
182 # SEQ_LIST is a regular expression:
183 STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
185 SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
190 # Populate GDCM_DATA_IMAGES:
191 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
192 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"
195 # Populate GDCM_DATA_SEQ_IMAGES:
196 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
197 "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n"
200 #-----------------------------------------------------------------------------
201 # Trying to solve a bizarre problem when loading shared lib if gdcm is static
202 # Therefore I disable the test when building SHAREDLIBS
203 IF(UNIX AND NOT BUILD_SHARED_LIBS)
204 ADD_LIBRARY(dynmodule MODULE dynmodule.cxx)
205 TARGET_LINK_LIBRARIES(dynmodule gdcm)
206 ADD_EXECUTABLE(loadmodule loadmodule.cxx )
207 TARGET_LINK_LIBRARIES(loadmodule gdcm -ldl)
208 ADD_TEST(loadmodule ${CXX_TEST_PATH}/loadmodule)
209 ENDIF(UNIX AND NOT BUILD_SHARED_LIBS)