]> Creatis software - gdcm.git/blob - Testing/CMakeLists.txt
remove tabs
[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   TestDcm2Acr.cxx
13   TestHash.cxx
14   TestWrite.cxx
15   TestWriteSimple.cxx
16 )
17
18 # add tests that require data
19 IF (GDCM_DATA_ROOT)
20   SET(TEST_SOURCES ${TEST_SOURCES}     
21     #PrintHeader.cxx       #require test.acr
22     PrintDocument.cxx     #require test.acr
23     PrintDicomDir.cxx
24     TestFindTags.cxx
25     TestChangeHeader.cxx
26     TestDicomDir.cxx      #require DICOMDIR
27     BuildUpDicomDir.cxx
28     TestReadWrite.cxx
29     makeDicomDir.cxx
30   )
31   # add test that require VTK:
32   IF(GDCM_VTK)
33     INCLUDE_DIRECTORIES(
34       ${GDCM_SOURCE_DIR}/vtk/
35       )
36     SET(TEST_SOURCES ${TEST_SOURCES}
37       ShowDicom.cxx    
38       )
39   ENDIF(GDCM_VTK)
40 ENDIF (GDCM_DATA_ROOT)
41
42
43
44 # include stuff
45 INCLUDE_DIRECTORIES(
46   ${GDCM_SOURCE_DIR}/src/
47   ${GDCM_BINARY_DIR}/
48 )
49
50 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
51 ADD_EXECUTABLE(gdcmTests ${Tests})
52 IF(GDCM_VTK)
53   TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
54 ELSE(GDCM_VTK)
55   TARGET_LINK_LIBRARIES(gdcmTests gdcm)
56 ENDIF(GDCM_VTK)
57
58 SET (TestsToRun ${Tests})
59 REMOVE (TestsToRun gdcmTests.cxx)
60
61 # Loop over files and create executables
62 FOREACH(file ${TEST_SOURCES})
63   GET_FILENAME_COMPONENT(name ${file} NAME_WE)
64 #  IF (GDCM_DATA_ROOT)
65 #    ADD_TEST(${name} ${GDCM_TESTS} ${name}
66 #        -D ${GDCM_DATA_ROOT}
67 #        -T ${GDCM_BINARY_DIR}/Testing/Temporary
68 #        -V Baseline/gdcm/${name}.png)
69 #  ELSE (GDCM_DATA_ROOT)
70     ADD_TEST(${name} ${GDCM_TESTS} ${name})
71 #  ENDIF (GDCM_DATA_ROOT)
72 ENDFOREACH(file ${TEST_SOURCES})
73
74 #-----------------------------------------------------------------------------
75
76 # We need to test the reading of all dicom images in the gdcmData directory
77 # First parse this directory and extract all images
78
79 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
80   FILE(GLOB GDCM_DATA_IMAGES_GLOB
81     "${GDCM_DATA_ROOT}/*.acr"
82     "${GDCM_DATA_ROOT}/*.dcm"
83     )
84 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)   
85   # Since there is a bug in cmake 1.8.3, I'll have to do two separate globs
86   FILE(GLOB GDCM_DATA_IMAGES_GLOB_ACR
87     "${GDCM_DATA_ROOT}/*.acr"
88     )
89   FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
90     "${GDCM_DATA_ROOT}/*.dcm"
91     )
92   SET(GDCM_DATA_IMAGES_GLOB ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR})
93   #SET(GDCM_DATA_IMAGES_GLOB  ${GDCM_DATA_IMAGES_GLOB_ACR})
94 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)   
95
96 # Black list of images known to break lots of readers (efilm, xmedcon ...):
97 SET(BLACK_LIST
98   "gdcm-JPEG-LossLessThoravision.dcm"
99   "cr172241.dcm"  #temporarily remove as it kills my gnome session (but not kde)
100   "emptyImage.dcm"  #the png looks ugly...
101   "gdcm-MR-PHILIPS-16-Multi-Seq.fixed.dcm" weird looks exactly the same as gdcm-MR-PHILIPS-16-Multi-Seq.dcm
102   "gdcm-MR-PHILIPS-16.dcm" png looks ugly
103   "irmPhlipsNew1.dcm" png looks ugly
104   "mriThruVPRO.dcm"   png looks ugly
105   "US.3405.1.dcm" looks exactly the same as US.1.2.dcm
106   )
107
108 #   gdcm-ACR-LibIDO seems to be cut
109 #   test.acr is very bright
110
111 # This is a GLOB expression, change it into a list separated with a comma and \n
112 SET(GDCM_DATA_IMAGES)
113 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
114   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
115   STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
116   IF(NOT bad_dicom)
117     SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
118   ENDIF(NOT bad_dicom)
119 ENDFOREACH(filename)
120
121 # Populate GDCM_DATA_IMAGES:
122 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
123   "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n" 
124   )