1 # CMakeLists for Testing purpose
2 # Cxx file that need a file to run should be place aproprietly
4 SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
6 SET(GDCM_TESTS ${CXX_TEST_PATH}/gdcmTests)
8 # add test that does not require data:
9 # They usally return if no argument is given
18 # add tests that require data
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
27 TestDicomDir.cxx # require DICOMDIR
28 BuildUpDicomDir.cxx # writes a file named "NewDICOMDIR"
29 makeDicomDir.cxx # writes a file named "NewDICOMDIR"
32 # add test that require VTK:
34 # Include the VTK library
35 INCLUDE(${VTK_USE_FILE})
38 ${GDCM_SOURCE_DIR}/vtk/
40 SET(TEST_SOURCES ${TEST_SOURCES}
44 ENDIF (GDCM_DATA_ROOT)
50 ${GDCM_SOURCE_DIR}/src/
54 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
55 ADD_EXECUTABLE(gdcmTests ${Tests})
57 TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
59 TARGET_LINK_LIBRARIES(gdcmTests gdcm)
62 SET (TestsToRun ${Tests})
63 REMOVE (TestsToRun gdcmTests.cxx)
65 # Loop over files and create executables
66 FOREACH(file ${TEST_SOURCES})
67 GET_FILENAME_COMPONENT(name ${file} NAME_WE)
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})
78 #-----------------------------------------------------------------------------
80 # We need to test the reading of all dicom images in the gdcmData directory
81 # First parse this directory and extract all images
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"
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"
95 FILE(GLOB GDCM_DATA_IMAGES_GLOB_DCM
96 "${GDCM_DATA_ROOT}/*.dcm"
98 FILE(GLOB GDCM_DATA_IMAGES_GLOB_NEMA
99 "${GDCM_DATA_ROOT}/*.nema"
101 FILE(GLOB GDCM_DATA_IMAGES_GLOB_IMA
102 "${GDCM_DATA_ROOT}/*.ima"
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)
110 # Black list of images known to break lots of readers (efilm, xmedcon ...):
112 # serial killer (also segfaults vtkgdcmViewer, but NOT PrintFile)
113 "gdcm-JPEG-LossLessThoravision.dcm"
115 # Mathieu: temporarily remove as it kills my gnome session (but not kde)
116 # JPR: also breaks TestReadWriteReadCompare : Pixel differ (as expanded
118 "KODAK-12-MONO1-Odd_Terminated_Sequence.dcm"
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
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})
134 SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
138 # Populate GDCM_DATA_IMAGES:
139 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
140 "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"