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