]> Creatis software - gdcm.git/blob - Testing/CMakeLists.txt
76814532f15fe7107499dfa0930c1fc56d8132a8
[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   TestBug.cxx
12   TestHash.cxx
13   TestTS.cxx
14   TestVR.cxx
15   TestDicomString.cxx
16 )
17
18 # add tests that require data
19 IF (GDCM_DATA_ROOT)
20   SET(TEST_SOURCES ${TEST_SOURCES}     
21     TestReadWriteReadCompare.cxx     # includes generated gdcmDataImages.h 
22     PrintAllDocument.cxx             # includes generated gdcmDataImages.h
23     TestAllReadCompareDicom.cxx      # includes generated gdcmDataImages.h
24     TestAllEntryVerify.cxx           # includes generated gdcmDataImages.h
25     PrintDicomDir.cxx
26     #TestChangeHeader.cxx
27     TestDicomDir.cxx                 # require DICOMDIR
28     BuildUpDicomDir.cxx              # writes a file named "NewDICOMDIR"
29     makeDicomDir.cxx                 # writes a file named "NewDICOMDIR"
30     TestCopyDicom.cxx
31   )
32   # add test that require VTK:
33   IF(GDCM_VTK)
34     INCLUDE_DIRECTORIES(
35       ${GDCM_SOURCE_DIR}/vtk/
36       )
37     SET(TEST_SOURCES ${TEST_SOURCES}
38       ShowDicom.cxx    
39       )
40   ENDIF(GDCM_VTK)
41 ENDIF (GDCM_DATA_ROOT)
42
43
44
45 # include stuff
46 INCLUDE_DIRECTORIES(
47   ${GDCM_SOURCE_DIR}/src/
48   ${GDCM_BINARY_DIR}/
49 )
50
51 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
52 ADD_EXECUTABLE(gdcmTests ${Tests})
53 IF(GDCM_VTK)
54   TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
55 ELSE(GDCM_VTK)
56   TARGET_LINK_LIBRARIES(gdcmTests gdcm)
57 ENDIF(GDCM_VTK)
58
59 SET (TestsToRun ${Tests})
60 REMOVE (TestsToRun gdcmTests.cxx)
61
62 # Loop over files and create executables
63 FOREACH(file ${TEST_SOURCES})
64   GET_FILENAME_COMPONENT(name ${file} NAME_WE)
65 #  IF (GDCM_DATA_ROOT)
66 #    ADD_TEST(${name} ${GDCM_TESTS} ${name}
67 #        -D ${GDCM_DATA_ROOT}
68 #        -T ${GDCM_BINARY_DIR}/Testing/Temporary
69 #        -V Baseline/gdcm/${name}.png)
70 #  ELSE (GDCM_DATA_ROOT)
71     ADD_TEST(${name} ${GDCM_TESTS} ${name})
72 #  ENDIF (GDCM_DATA_ROOT)
73 ENDFOREACH(file ${TEST_SOURCES})
74
75 #-----------------------------------------------------------------------------
76
77 # We need to test the reading of all dicom images in the gdcmData directory
78 # First parse this directory and extract all images
79
80 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
81   FILE(GLOB GDCM_DATA_IMAGES_GLOB
82     "${GDCM_DATA_ROOT}/*.acr"
83     "${GDCM_DATA_ROOT}/*.dcm"
84     "${GDCM_DATA_ROOT}/*.nema"
85     "${GDCM_DATA_ROOT}/*.ima"
86     )
87 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)   
88   # Since there is a bug in cmake 1.8.3, I'll have to do two separate globs
89   FILE(GLOB GDCM_DATA_IMAGES_GLOB_ACR
90     "${GDCM_DATA_ROOT}/*.acr"
91     )
92   FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
93     "${GDCM_DATA_ROOT}/*.dcm"
94     )
95   FILE(GLOB GDCM_DATA_IMAGES_GLOB_NEMA
96     "${GDCM_DATA_ROOT}/*.nema"
97     )
98   FILE(GLOB GDCM_DATA_IMAGES_GLOB_IMA
99     "${GDCM_DATA_ROOT}/*.ima"
100     )
101   SET(GDCM_DATA_IMAGES_GLOB 
102     ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR}
103     ${GDCM_DATA_IMAGES_GLOB_NEMA} ${GDCM_DATA_IMAGES_GLOB_IMA})
104   #SET(GDCM_DATA_IMAGES_GLOB  ${GDCM_DATA_IMAGES_GLOB_ACR})
105 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)   
106
107 # Black list of images known to break lots of readers (efilm, xmedcon ...):
108 SET(BLACK_LIST
109   # serial killer (also segfaults vtkgdcmViewer, but NOT PrintFile)
110   "gdcm-JPEG-LossLessThoravision.dcm"
111   
112   # Mathieu: temporarily remove as it kills my gnome session (but not kde)
113   # JPR: also breaks TestReadWriteReadCompare : Pixel differ (as expanded
114   #      in memory)  
115   "KODAK-12-MONO1-Odd_Terminated_Sequence.dcm"
116   )
117
118 IF(APPLE)
119   SET(BLACK_LIST ${BLACK_LIST}
120     "SIEMENS_GBS_III-16-ACR_NEMA_1.acr"  # This image contains a wrong length
121     # Which led us to read pass the end of the file. This seg fault on MacOSX
122     )
123 ENDIF(APPLE)
124
125 # This is a GLOB expression, change it into a list separated with a comma and \n
126 SET(GDCM_DATA_IMAGES)
127 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
128   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
129   STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
130   IF(NOT bad_dicom)
131     SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
132   ENDIF(NOT bad_dicom)
133 ENDFOREACH(filename)
134
135 # Populate GDCM_DATA_IMAGES:
136 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
137   "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n" 
138   )