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