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