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