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
21 TestDicomDirElement.cxx
26 # add tests that require data
28 SET(TEST_SOURCES ${TEST_SOURCES}
31 TestLoadAllDocumentsNoPrivNoSeq.cxx # includes generated gdcmDataImages.h
32 TestPrintAllDocument.cxx # includes generated gdcmDataImages.h
33 #TestAllEntryVerify.cxx # includes generated gdcmDataImages.h
34 TestAllReadCompareDicom.cxx # includes generated gdcmDataImages.h
35 TestReadWriteReadCompare.cxx # includes generated gdcmDataImages.h
36 #TestCopyDicom.cxx # includes generated gdcmDataImages.h
37 # TestCopyRescaleDicom.cxx # includes generated gdcmDataImages.h
41 TestDicomDir.cxx # require DICOMDIR
42 TestBuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
43 TestMakeDicomDir.cxx # writes a file named "NewDICOMDIR"
44 TestSerieHelper.cxx # uses gdcmData as a default root directory
47 # add test that require VTK:
49 IF("${VTK_MAJOR_VERSION}" LESS 4)
50 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
51 ELSE("${VTK_MAJOR_VERSION}" LESS 4)
52 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
53 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
54 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
55 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
56 IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
57 MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
58 "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
59 ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
60 # Include the VTK library since we know this is going to work
61 INCLUDE(${VTK_USE_FILE})
64 ${GDCM_SOURCE_DIR}/vtk
66 SET(TEST_SOURCES ${TEST_SOURCES}
72 ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
74 ENDIF (GDCM_DATA_ROOT)
80 ${GDCM_SOURCE_DIR}/src
84 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
85 ADD_EXECUTABLE(gdcmTests ${Tests})
87 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
89 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
92 SET (TestsToRun ${Tests})
93 REMOVE (TestsToRun gdcmTests.cxx)
95 # Loop over files and create executables
96 FOREACH(file ${TEST_SOURCES})
97 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
98 ADD_TEST(${name} ${GDCM_TESTS} ${name})
99 ENDFOREACH(file ${TEST_SOURCES})
101 #-----------------------------------------------------------------------------
103 # We need to test the reading of all dicom images in the gdcmData directory
104 # First parse this directory and extract all images
106 FILE(GLOB GDCM_DATA_IMAGES_GLOB
107 "${GDCM_DATA_ROOT}/*.acr"
108 "${GDCM_DATA_ROOT}/*.dcm"
109 "${GDCM_DATA_ROOT}/*.nema"
110 "${GDCM_DATA_ROOT}/*.ima"
113 # Black list of images known to break lots of readers (efilm, xmedcon ...):
115 # Multiframe Papyrus format image
116 # Just to remember this format exists, and is gdcm::File compliant
117 # (NOT gdcm::FileHelper ...)
118 # any contribution is welcome
119 "PET-cardio-Multiframe-Papyrus.dcm"
120 # From David Clunie's Compresion Dataset
121 "D_CLUNIE_CT1_JLSN.dcm"
122 "D_CLUNIE_CT1_JLSL.dcm"
123 #Not a Dicom Image, but a RT Object
124 "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm"
126 "ETIAM_video_002.dcm"
127 #Something stupid occured in the code for LibIDO images.
128 #I Black list them for a while. JP
129 "gdcm-ACR-LibIDO.acr"
130 "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
131 #16 Bits per pixel images with LUT 16 Bits.
132 #I wait to be 100% sure before releasing them. JP
135 # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
136 # but then it breaks other images...
137 "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
141 # I probabely messed up smething with the .png, .tst of
142 # the images I recently added to the Test Suite
143 # I Black list them, until I find where is the pb.
144 "US-RGB-8-esopecho.dcm"
145 "MR_Philips_Intera_No_PrivateSequenceImplicitVR.dcm"
146 "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
147 "MR_SIEMENS_forceLoad29-1010_29-1020.dcm"
148 # An element contains a value of 4, but no data follows
149 # So, the next (group, elem) is not correctly read
150 "gdcm-MR-PHILIPS-16-Multi-Seq.dcm"
153 # Create a specific list of dicom files that we know are part of a sequence
155 "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
158 # Add a special test that requires dciodvfy from dicom3tools
159 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
161 # This is a GLOB expression, change it into a list separated with a comma and \n
162 SET(GDCM_DATA_IMAGES)
163 SET(GDCM_DATA_SEQ_IMAGES)
164 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
165 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
167 ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
168 ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
169 ENDIF(DCIODVFY_FOUND)
170 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
172 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
173 # SEQ_LIST is a regular expression:
174 STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
176 SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
181 # Populate GDCM_DATA_IMAGES:
182 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
183 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"
186 # Populate GDCM_DATA_SEQ_IMAGES:
187 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
188 "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n"
191 #-----------------------------------------------------------------------------
192 # Trying to solve a bizarre problem when loading shared lib if gdcm is static
193 # Therefore I disable the test when building SHAREDLIBS
194 IF(UNIX AND NOT GDCM_BUILD_SHARED_LIBS)
195 ADD_LIBRARY(dynmodule MODULE dynmodule.cxx)
196 TARGET_LINK_LIBRARIES(dynmodule gdcm)
197 ADD_EXECUTABLE(loadmodule loadmodule.cxx )
198 TARGET_LINK_LIBRARIES(loadmodule gdcm -ldl)
199 ADD_TEST(loadmodule ${CXX_TEST_PATH}/loadmodule)
200 ENDIF(UNIX AND NOT GDCM_BUILD_SHARED_LIBS)