]> Creatis software - gdcm.git/blob - Testing/CMakeLists.txt
Add a *really* empty test, to know if gdcm dll is loadable or not :-(
[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   TestEmpty.cxx
12   TestUtil.cxx
13   TestBug.cxx
14   TestHash.cxx
15   TestCommand.cxx
16   TestTS.cxx
17   TestVR.cxx
18   TestDictGroupName.cxx
19   TestDict.cxx
20   TestDataEntry.cxx
21   TestWriteSimple.cxx
22   TestImageSet.cxx
23   TestDicomDirElement.cxx
24   TestDicomString.cxx
25   TestEnumVR.cxx
26
27 )
28 IF(UNIX)
29   SET(TEST_SOURCES ${TEST_SOURCES}
30     #TestInline.cxx
31   )
32 ENDIF(UNIX)
33
34 # add tests that require data
35 IF (GDCM_DATA_ROOT)
36   SET(TEST_SOURCES ${TEST_SOURCES}
37     TestFileAccessors.cxx
38     TestMakeIcon.cxx
39     TestLoadAllDocumentsNoPrivNoSeq.cxx # includes generated gdcmDataImages.h
40     TestPrintAllDocument.cxx         # includes generated gdcmDataImages.h
41     #TestAllEntryVerify.cxx           # includes generated gdcmDataImages.h
42     TestAllReadCompareDicom.cxx      # includes generated gdcmDataImages.h
43     TestReadWriteReadCompare.cxx     # includes generated gdcmDataImages.h 
44     #TestCopyDicom.cxx                # includes generated gdcmDataImages.h 
45     #    TestCopyRescaleDicom.cxx         # includes generated gdcmDataImages.h 
46     #TestChangeHeader.cxx
47     #    TestAnonymize.cxx
48     TestDirList.cxx
49     TestDicomDir.cxx                 # require DICOMDIR
50     TestBuildUpDicomDir.cxx          # writes a file named "NewDICOMDIR"
51     TestMakeDicomDir.cxx             # writes a file named "NewDICOMDIR"
52     TestSerieHelper.cxx              # uses gdcmData as a default root directory    
53     TestAllVM.cxx
54     TestValidate.cxx                 #Just to have on overviews of oddities ...  
55   )
56   # add test that require VTK:
57   IF(GDCM_VTK)
58     IF("${VTK_MAJOR_VERSION}" LESS 4)
59       MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
60     ELSE("${VTK_MAJOR_VERSION}" LESS 4)
61       IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
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 2)
65       IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
66         MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
67                              "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
68       ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
69       # Include the VTK library since we know this is going to work
70       INCLUDE(${VTK_USE_FILE})
71
72       INCLUDE_DIRECTORIES(
73         ${GDCM_SOURCE_DIR}/vtk
74       )
75       SET(TEST_SOURCES ${TEST_SOURCES}
76         VTKTestRead.cxx
77         VTKTestReadSeq.cxx
78         VTKTestWrite.cxx
79         VTKTestWriteSeq.cxx
80       )
81     ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
82   ENDIF(GDCM_VTK)
83 ENDIF (GDCM_DATA_ROOT)
84
85
86
87 # include stuff
88 INCLUDE_DIRECTORIES(
89   ${GDCM_SOURCE_DIR}/src
90   ${GDCM_BINARY_DIR}
91 )
92
93 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
94 ADD_EXECUTABLE(gdcmTests ${Tests})
95 IF(GDCM_VTK)
96   IF(GDCM_DATA_ROOT)
97     TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
98   ELSE(GDCM_DATA_ROOT)
99     TARGET_LINK_LIBRARIES(gdcmTests gdcm)
100   ENDIF(GDCM_DATA_ROOT)     
101 ELSE(GDCM_VTK)
102   TARGET_LINK_LIBRARIES(gdcmTests gdcm)
103 ENDIF(GDCM_VTK)
104
105 SET (TestsToRun ${Tests})
106 REMOVE (TestsToRun gdcmTests.cxx)
107
108 # Loop over files and create executables
109 FOREACH(file ${TEST_SOURCES})
110   GET_FILENAME_COMPONENT(name ${file} NAME_WE)
111   ADD_TEST(${name} ${GDCM_TESTS} ${name})
112 ENDFOREACH(file ${TEST_SOURCES})
113
114 #-----------------------------------------------------------------------------
115
116 # We need to test the reading of all dicom images in the gdcmData directory
117 # First parse this directory and extract all images
118
119 FILE(GLOB GDCM_DATA_IMAGES_GLOB
120   "${GDCM_DATA_ROOT}/*.acr"
121   "${GDCM_DATA_ROOT}/*.dcm"
122   "${GDCM_DATA_ROOT}/*.nema"
123   "${GDCM_DATA_ROOT}/*.ima"
124   )
125
126 # Black list of images known to break lots of readers (efilm, xmedcon ...):
127 SET(BLACK_LIST
128   # Multiframe Papyrus format image
129   # Just to remember this format exists, and is gdcm::File compliant
130   # (NOT gdcm::FileHelper ...)
131   # any contribution is welcome
132   "PET-cardio-Multiframe-Papyrus.dcm"
133   # From David Clunie's Compresion Dataset  
134   "D_CLUNIE_CT1_JLSN.dcm"
135   "D_CLUNIE_CT1_JLSL.dcm"
136   #Not a Dicom Image, but a RT Object
137   "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm" 
138   #Dicom MPEG image
139   "ETIAM_video_002.dcm"
140   #Something stupid occured in the code for LibIDO images.
141   #I Black list them for a while. JP
142   #"gdcm-ACR-LibIDO.acr"
143   "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
144   #16 Bits per pixel images with LUT 16 Bits.
145   #I wait to be 100% sure before releasing them. JP
146   "rle16sti.dcm"
147   "rle16loo.dcm"   
148   # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
149   # but then it breaks other images...
150   "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
151   #
152   # ------------
153   #  
154   #Still cause troubles (see the .README.txt file for more details)  
155   "MR_Philips_Intera_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"  
156   "MR_Philips_Intera_PrivateSequenceExplicitVR.dcm" 
157   #The 2 previous images are identical !
158   #--> Replaced by more significant name
159   "MR_Philips_Intera_PrivateSequenceExplicitVR_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"
160
161   #hexedit shows something *very* strange around offset 0x76e !
162   #the images looks *over*corrupted (on disc, not from the manufacturer!)
163   "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
164   
165   # Seems this one hangs on 64 bits processors ?!?
166   # I blacklist it untill the pb is solved.
167   # (to get some more green on the Dasboards)
168   "MR_Philips-Intera_BreaksNOSHADOW.dcm"
169   )
170
171 # Create a specific list of dicom files that we know are part of a sequence
172 SET(SEQ_LIST
173   "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
174   )
175
176 # Add a special test that requires dciodvfy from dicom3tools
177 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
178
179 # This is a GLOB expression, change it into a list separated with a comma and \n
180 SET(GDCM_DATA_IMAGES)
181 SET(GDCM_DATA_SEQ_IMAGES)
182 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
183   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
184   IF(DCIODVFY_FOUND)
185     ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
186     ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
187   ENDIF(DCIODVFY_FOUND)
188   STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
189   IF(NOT bad_dicom)
190     SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
191     # SEQ_LIST is a regular expression:
192     STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
193     IF(is_seq)
194       SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
195     ENDIF(is_seq)
196   ENDIF(NOT bad_dicom)
197 ENDFOREACH(filename)
198
199 # Populate GDCM_DATA_IMAGES:
200 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
201   "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n" 
202 )
203
204 # Populate GDCM_DATA_SEQ_IMAGES:
205 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
206   "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n" 
207 )
208
209 #-----------------------------------------------------------------------------
210 # Trying to solve a bizarre problem when loading shared lib if gdcm is static
211 # Therefore I disable the test when building SHAREDLIBS
212 IF(UNIX AND NOT BUILD_SHARED_LIBS)
213   ADD_LIBRARY(dynmodule MODULE dynmodule.cxx)
214   TARGET_LINK_LIBRARIES(dynmodule gdcm)
215   ADD_EXECUTABLE(loadmodule loadmodule.cxx )
216   TARGET_LINK_LIBRARIES(loadmodule gdcm -ldl)
217   ADD_TEST(loadmodule ${CXX_TEST_PATH}/loadmodule)
218 ENDIF(UNIX AND NOT BUILD_SHARED_LIBS)
219
220
221 #-----------------------------------------------------------------------------
222 # Do the build against an installed gdcm
223 SET(GDCM_TEST_INSTALL_LEFT "${CMAKE_INSTALL_PREFIX}")
224 SET(GDCM_TEST_INSTALL_RIGHT "${GDCM_BINARY_DIR}/InstallTest/Root")
225 STRING(COMPARE EQUAL "${GDCM_TEST_INSTALL_LEFT}" "${GDCM_TEST_INSTALL_RIGHT}"
226   GDCM_TEST_INSTALL)
227 IF(GDCM_TEST_INSTALL)
228   ADD_TEST(Install
229     ${CMAKE_CTEST_COMMAND}
230     #  ${GDCM_INSTALL_TEST_CONFIG_TYPE}
231     --build-and-test ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
232     --build-generator ${CMAKE_GENERATOR}
233     --build-project GDCM
234     --build-makeprogram ${CMAKE_MAKE_PROGRAM}
235     --build-noclean
236     --build-target install)
237 ENDIF(GDCM_TEST_INSTALL)
238