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
19 # add tests that require data
21 SET(TEST_SOURCES ${TEST_SOURCES}
22 TestReadWriteReadCompare.cxx # includes generated gdcmDataImages.h
23 PrintAllDocument.cxx # includes generated gdcmDataImages.h
24 TestAllReadCompareDicom.cxx # includes generated gdcmDataImages.h
25 TestAllEntryVerify.cxx # includes generated gdcmDataImages.h
28 TestDicomDir.cxx # require DICOMDIR
29 BuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
30 makeDicomDir.cxx # writes a file named "NewDICOMDIR"
32 TestCopyRescaleDicom.cxx
35 # add test that require VTK:
37 # Include the VTK library
38 INCLUDE(${VTK_USE_FILE})
41 ${GDCM_SOURCE_DIR}/vtk/
43 SET(TEST_SOURCES ${TEST_SOURCES}
49 ENDIF (GDCM_DATA_ROOT)
55 ${GDCM_SOURCE_DIR}/src/
59 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
60 ADD_EXECUTABLE(gdcmTests ${Tests})
62 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
64 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
67 SET (TestsToRun ${Tests})
68 REMOVE (TestsToRun gdcmTests.cxx)
70 # Loop over files and create executables
71 FOREACH(file ${TEST_SOURCES})
72 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
74 # ADD_TEST(${name} ${GDCM_TESTS} ${name}
75 # -D ${GDCM_DATA_ROOT}
76 # -T ${GDCM_BINARY_DIR}/Testing/Temporary
77 # -V Baseline/gdcm/${name}.png)
78 # ELSE (GDCM_DATA_ROOT)
79 ADD_TEST(${name} ${GDCM_TESTS} ${name})
80 # ENDIF (GDCM_DATA_ROOT)
81 ENDFOREACH(file ${TEST_SOURCES})
83 #-----------------------------------------------------------------------------
85 # We need to test the reading of all dicom images in the gdcmData directory
86 # First parse this directory and extract all images
88 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
89 FILE(GLOB GDCM_DATA_IMAGES_GLOB
90 "${GDCM_DATA_ROOT}/*.acr"
91 "${GDCM_DATA_ROOT}/*.dcm"
92 "${GDCM_DATA_ROOT}/*.nema"
93 "${GDCM_DATA_ROOT}/*.ima"
95 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB
96 "${GDCM_DATA_ROOT}/*FileSeq0.acr"
97 "${GDCM_DATA_ROOT}/*FileSeq0.dcm"
98 "${GDCM_DATA_ROOT}/*FileSeq0.nema"
99 "${GDCM_DATA_ROOT}/*FileSeq0.ima"
101 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
102 # Since there is a bug in cmake 1.8.3, I'll have to do two separate globs
103 FILE(GLOB GDCM_DATA_IMAGES_GLOB_ACR
104 "${GDCM_DATA_ROOT}/*.acr"
106 FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
107 "${GDCM_DATA_ROOT}/*.dcm"
109 FILE(GLOB GDCM_DATA_IMAGES_GLOB_NEMA
110 "${GDCM_DATA_ROOT}/*.nema"
112 FILE(GLOB GDCM_DATA_IMAGES_GLOB_IMA
113 "${GDCM_DATA_ROOT}/*.ima"
115 SET(GDCM_DATA_IMAGES_GLOB
116 ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR}
117 ${GDCM_DATA_IMAGES_GLOB_NEMA} ${GDCM_DATA_IMAGES_GLOB_IMA})
119 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_ACR
120 "${GDCM_DATA_ROOT}/*FileSeq0.acr"
122 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_DCM
123 "${GDCM_DATA_ROOT}/*FileSeq0.dcm"
125 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_NEMA
126 "${GDCM_DATA_ROOT}/*FileSeq0.nema"
128 FILE(GLOB GDCM_DATA_SEQ_IMAGES_GLOB_IMA
129 "${GDCM_DATA_ROOT}/*FileSeq0.ima"
131 SET(GDCM_DATA_SEQ_IMAGES_GLOB
132 ${GDCM_DATA_SEQ_IMAGES_GLOB_DCM} ${GDCM_DATA_SEQ_IMAGES_GLOB_ACR}
133 ${GDCM_DATA_SEQ_IMAGES_GLOB_NEMA} ${GDCM_DATA_SEQ_IMAGES_GLOB_IMA})
134 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
136 # Black list of images known to break lots of readers (efilm, xmedcon ...):
138 # serial killer (also segfaults vtkgdcmViewer, but NOT PrintFile)
139 "gdcm-JPEG-LossLessThoravision.dcm"
141 # Mathieu: temporarily remove as it kills my gnome session (but not kde)
142 # JPR: also breaks TestReadWriteReadCompare : Pixel differ (as expanded
144 "KODAK-12-MONO1-Odd_Terminated_Sequence.dcm"
147 # This is a GLOB expression, change it into a list separated with a comma and \n
148 SET(GDCM_DATA_IMAGES)
149 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
150 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
151 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
153 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
157 SET(GDCM_DATA_SEQ_IMAGES)
158 FOREACH(filename ${GDCM_DATA_SEQ_IMAGES_GLOB})
159 GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
160 STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
162 STRING(REGEX REPLACE "(.*)FileSeq0(.*)" "\\1FileSeq%d\\2" filename_temp2 ${filename_temp})
164 SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp2}\",")
168 # Populate GDCM_DATA_IMAGES:
169 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
170 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"
173 # Populate GDCM_DATA_SEQ_IMAGES:
174 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
175 "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n"