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