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