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