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