]> Creatis software - gdcm.git/blob - Testing/CMakeLists.txt
Enforce TestValidate, and run it.
[gdcm.git] / Testing / CMakeLists.txt
1 # CMakeLists for Testing purpose
2 # Cxx file that need a file to run should be place aproprietly
3
4 SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
5
6 SET(GDCM_TESTS ${CXX_TEST_PATH}/gdcmTests)
7
8 # add test that does not require data:
9 # They usally return if no argument is given
10 SET(TEST_SOURCES
11   TestUtil.cxx
12   TestBug.cxx
13   TestHash.cxx
14   TestTS.cxx
15   TestVR.cxx
16   TestDictGroupName.cxx
17   TestDict.cxx
18   TestDataEntry.cxx
19   TestWriteSimple.cxx
20   TestImageSet.cxx
21   TestDicomDirElement.cxx
22   TestDicomString.cxx
23
24 )
25 IF(UNIX)
26   SET(TEST_SOURCES ${TEST_SOURCES}
27     TestInline.cxx
28   )
29 ENDIF(UNIX)
30
31 # add tests that require data
32 IF (GDCM_DATA_ROOT)
33   SET(TEST_SOURCES ${TEST_SOURCES}
34     TestFileAccessors.cxx
35     TestMakeIcon.cxx
36     TestLoadAllDocumentsNoPrivNoSeq.cxx # includes generated gdcmDataImages.h
37     TestPrintAllDocument.cxx         # includes generated gdcmDataImages.h
38     #TestAllEntryVerify.cxx           # includes generated gdcmDataImages.h
39     TestAllReadCompareDicom.cxx      # includes generated gdcmDataImages.h
40     TestReadWriteReadCompare.cxx     # includes generated gdcmDataImages.h 
41     #TestCopyDicom.cxx                # includes generated gdcmDataImages.h 
42     #    TestCopyRescaleDicom.cxx         # includes generated gdcmDataImages.h 
43     #TestChangeHeader.cxx
44     #    TestAnonymize.cxx
45     TestDirList.cxx
46     TestDicomDir.cxx                 # require DICOMDIR
47     TestBuildUpDicomDir.cxx          # writes a file named "NewDICOMDIR"
48     TestMakeDicomDir.cxx             # writes a file named "NewDICOMDIR"
49     TestSerieHelper.cxx              # uses gdcmData as a default root directory    
50     TestAllVM.cxx
51     TestValidate.cxx                 #Just to have on overviews of oddities ...  
52   )
53   # add test that require VTK:
54   IF(GDCM_VTK)
55     IF("${VTK_MAJOR_VERSION}" LESS 4)
56       MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
57     ELSE("${VTK_MAJOR_VERSION}" LESS 4)
58       IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
59         MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
60                              "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
61       ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
62       IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
63         MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
64                              "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
65       ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
66       # Include the VTK library since we know this is going to work
67       INCLUDE(${VTK_USE_FILE})
68
69       INCLUDE_DIRECTORIES(
70         ${GDCM_SOURCE_DIR}/vtk
71       )
72       SET(TEST_SOURCES ${TEST_SOURCES}
73         VTKTestRead.cxx
74         VTKTestReadSeq.cxx
75         VTKTestWrite.cxx
76         VTKTestWriteSeq.cxx
77       )
78     ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
79   ENDIF(GDCM_VTK)
80 ENDIF (GDCM_DATA_ROOT)
81
82
83
84 # include stuff
85 INCLUDE_DIRECTORIES(
86   ${GDCM_SOURCE_DIR}/src
87   ${GDCM_BINARY_DIR}
88 )
89
90 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
91 ADD_EXECUTABLE(gdcmTests ${Tests})
92 IF(GDCM_VTK)
93   TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
94 ELSE(GDCM_VTK)
95   TARGET_LINK_LIBRARIES(gdcmTests gdcm)
96 ENDIF(GDCM_VTK)
97
98 SET (TestsToRun ${Tests})
99 REMOVE (TestsToRun gdcmTests.cxx)
100
101 # Loop over files and create executables
102 FOREACH(file ${TEST_SOURCES})
103   GET_FILENAME_COMPONENT(name ${file} NAME_WE)
104   ADD_TEST(${name} ${GDCM_TESTS} ${name})
105 ENDFOREACH(file ${TEST_SOURCES})
106
107 #-----------------------------------------------------------------------------
108
109 # We need to test the reading of all dicom images in the gdcmData directory
110 # First parse this directory and extract all images
111
112 FILE(GLOB GDCM_DATA_IMAGES_GLOB
113   "${GDCM_DATA_ROOT}/*.acr"
114   "${GDCM_DATA_ROOT}/*.dcm"
115   "${GDCM_DATA_ROOT}/*.nema"
116   "${GDCM_DATA_ROOT}/*.ima"
117   )
118
119 # Black list of images known to break lots of readers (efilm, xmedcon ...):
120 SET(BLACK_LIST
121   # Multiframe Papyrus format image
122   # Just to remember this format exists, and is gdcm::File compliant
123   # (NOT gdcm::FileHelper ...)
124   # any contribution is welcome
125   "PET-cardio-Multiframe-Papyrus.dcm"
126   # From David Clunie's Compresion Dataset  
127   "D_CLUNIE_CT1_JLSN.dcm"
128   "D_CLUNIE_CT1_JLSL.dcm"
129   #Not a Dicom Image, but a RT Object
130   "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm" 
131   #Dicom MPEG image
132   "ETIAM_video_002.dcm"
133   #Something stupid occured in the code for LibIDO images.
134   #I Black list them for a while. JP
135   "gdcm-ACR-LibIDO.acr"
136   "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
137   #16 Bits per pixel images with LUT 16 Bits.
138   #I wait to be 100% sure before releasing them. JP
139   "rle16sti.dcm"
140   "rle16loo.dcm"   
141   # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
142   # but then it breaks other images...
143   "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
144   #
145   # ------------
146   #
147   # I probabely messed up smething with the .png, .tst of
148   # the images I recently added to the Test Suite
149   # I Black list them, until I find where is the pb.
150   "US-RGB-8-esopecho.dcm"
151   "MR_Philips_Intera_No_PrivateSequenceImplicitVR.dcm"
152   "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
153   "MR_SIEMENS_forceLoad29-1010_29-1020.dcm"
154   # An element contains a value of 4, but no data follows
155   # So, the next (group, elem) is not correctly read
156   "gdcm-MR-PHILIPS-16-Multi-Seq.dcm"
157   )
158
159 # Create a specific list of dicom files that we know are part of a sequence
160 SET(SEQ_LIST
161   "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
162   )
163
164 # Add a special test that requires dciodvfy from dicom3tools
165 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
166
167 # This is a GLOB expression, change it into a list separated with a comma and \n
168 SET(GDCM_DATA_IMAGES)
169 SET(GDCM_DATA_SEQ_IMAGES)
170 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
171   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
172   IF(DCIODVFY_FOUND)
173     ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
174     ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
175   ENDIF(DCIODVFY_FOUND)
176   STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
177   IF(NOT bad_dicom)
178     SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
179     # SEQ_LIST is a regular expression:
180     STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
181     IF(is_seq)
182       SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
183     ENDIF(is_seq)
184   ENDIF(NOT bad_dicom)
185 ENDFOREACH(filename)
186
187 # Populate GDCM_DATA_IMAGES:
188 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
189   "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n" 
190 )
191
192 # Populate GDCM_DATA_SEQ_IMAGES:
193 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
194   "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n" 
195 )
196
197 #-----------------------------------------------------------------------------
198 # Trying to solve a bizarre problem when loading shared lib if gdcm is static
199 # Therefore I disable the test when building SHAREDLIBS
200 IF(UNIX AND NOT GDCM_BUILD_SHARED_LIBS)
201   ADD_LIBRARY(dynmodule MODULE dynmodule.cxx)
202   TARGET_LINK_LIBRARIES(dynmodule gdcm)
203   ADD_EXECUTABLE(loadmodule loadmodule.cxx )
204   TARGET_LINK_LIBRARIES(loadmodule gdcm -ldl)
205   ADD_TEST(loadmodule ${CXX_TEST_PATH}/loadmodule)
206 ENDIF(UNIX AND NOT GDCM_BUILD_SHARED_LIBS)
207
208
209