]> Creatis software - gdcm.git/blob - Testing/CMakeLists.txt
Add a new test: ShowDicom, for now this is just the c++ version of
[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   PrintBug.cxx
12   dcm2acr.cxx
13   hashtest.cxx
14   testWrite.cxx
15 )
16
17 # add tests that require data
18 IF (GDCM_DATA_ROOT)
19   SET(TEST_SOURCES ${TEST_SOURCES}     
20     PrintHeader.cxx       #require test.acr
21     PrintDicomDir.cxx
22     pourFindTaggs.cxx
23     testChangeEntete.cxx
24     testDicomDir.cxx      #require DICOMDIR
25     BuildUpDicomDir.cxx
26     TestReadWrite.cxx
27     makeDicomDir.cxx
28   )
29   # add test that require VTK:
30   IF(GDCM_VTK)
31     INCLUDE_DIRECTORIES(
32       ${GDCM_SOURCE_DIR}/vtk/
33       )
34     SET(TEST_SOURCES ${TEST_SOURCES}
35       ShowDicom.cxx    
36       )
37   ENDIF(GDCM_VTK)
38 ENDIF (GDCM_DATA_ROOT)
39
40
41
42 # include stuff
43 INCLUDE_DIRECTORIES(
44   ${GDCM_SOURCE_DIR}/src/
45   ${GDCM_BINARY_DIR}/
46 )
47
48 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
49 ADD_EXECUTABLE(gdcmTests ${Tests})
50 IF(GDCM_VTK)
51   TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
52 ELSE(GDCM_VTK)
53   TARGET_LINK_LIBRARIES(gdcmTests gdcm)
54 ENDIF(GDCM_VTK)
55
56 SET (TestsToRun ${Tests})
57 REMOVE (TestsToRun gdcmTests.cxx)
58
59 # Loop over files and create executables
60 FOREACH(file ${TEST_SOURCES})
61   GET_FILENAME_COMPONENT(name ${file} NAME_WE)
62 #  IF (GDCM_DATA_ROOT)
63 #    ADD_TEST(${name} ${CXX_TEST_PATH}/gdcmTests ${name}
64 #        -D ${GDCM_DATA_ROOT}
65 #        -T ${GDCM_BINARY_DIR}/Testing/Temporary
66 #        -V Baseline/gdcm/${name}.png)
67 #  ELSE (GDCM_DATA_ROOT)
68     ADD_TEST(${name} ${GDCM_TESTS} ${name})
69 #  ENDIF (GDCM_DATA_ROOT)
70 ENDFOREACH(file ${TEST_SOURCES})
71
72 #-----------------------------------------------------------------------------
73
74 # We need to test the reading of all dicom images in the gdcmData directory
75 # First parse this directory and extract all images
76
77 # For now only *.dcm will be picked up, since there is a bug in cmake 1.8.3
78 # and I don't know how to work around
79 FILE(GLOB GDCM_DATA_IMAGES_GLOB 
80   "${GDCM_DATA_ROOT}/*.dcm"
81 #  "${GDCM_DATA_ROOT}/*.acr"
82   )
83
84 # This is a GLOB expression, change it into a list separated with a comma and \n
85 SET(GDCM_DATA_IMAGES)
86 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
87   SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename}\",")
88 ENDFOREACH(filename)
89
90 # Populate GDCM_DATA_IMAGES:
91 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h.in"
92   "const char * const gdcmDataImages[] = { @GDCM_DATA_IMAGES@ \n 0 };" 
93   )
94
95 # Generate the header file:
96 CONFIGURE_FILE(
97   ${GDCM_BINARY_DIR}/gdcmDataImages.h.in
98   ${GDCM_BINARY_DIR}/gdcmDataImages.h
99   )