-#For later : rewrite this things for more consistencies, such as a 'FOREACH'
+# CMakeLists for Testing purpose
+# Cxx file that need a file to run should be place aproprietly
-LINK_LIBRARIES(gdcm)
-INCLUDE_DIRECTORIES(
- ${GDCM_SOURCE_DIR}/src/
-)
+SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
-SET(PrintHeader_SOURCES
- PrintHeader.cxx
-)
-ADD_EXECUTABLE(PrintHeader ${PrintHeader_SOURCES})
+SET(GDCM_TESTS ${CXX_TEST_PATH}/gdcmTests)
-SET(testWrite_SOURCES
+# add test that does not require data:
+# They usally return if no argument is given
+SET(TEST_SOURCES
+ PrintBug.cxx
+ dcm2acr.cxx
+ hashtest.cxx
testWrite.cxx
)
-ADD_EXECUTABLE(testWrite ${testWrite_SOURCES})
-SET(testChangeEntete_SOURCES
- testChangeEntete.cxx
-)
-ADD_EXECUTABLE(testChangeEntete ${testChangeEntete_SOURCES})
+# add tests that require data
+IF (GDCM_DATA_ROOT)
+ SET(TEST_SOURCES ${TEST_SOURCES}
+ PrintHeader.cxx #require test.acr
+ PrintDicomDir.cxx
+ pourFindTaggs.cxx
+ testChangeEntete.cxx
+ testDicomDir.cxx #require DICOMDIR
+ BuildUpDicomDir.cxx
+ TestReadWrite.cxx
+ makeDicomDir.cxx
+ )
+ # add test that require VTK:
+ IF(GDCM_VTK)
+ INCLUDE_DIRECTORIES(
+ ${GDCM_SOURCE_DIR}/vtk/
+ )
+ SET(TEST_SOURCES ${TEST_SOURCES}
+ ShowDicom.cxx
+ )
+ ENDIF(GDCM_VTK)
+ENDIF (GDCM_DATA_ROOT)
-SET(hashtest_SOURCES
- hashtest.cxx
-)
-ADD_EXECUTABLE(hashtest ${hashtest_SOURCES})
-SET(bug1_SOURCES
- bug1.cxx
-)
-ADD_EXECUTABLE(bug1 ${bug1_SOURCES})
-SET(pourFindTaggs_SOURCES
- pourFindTaggs.cxx
+# include stuff
+INCLUDE_DIRECTORIES(
+ ${GDCM_SOURCE_DIR}/src/
+ ${GDCM_BINARY_DIR}/
)
-ADD_EXECUTABLE(pourFindTaggs ${pourFindTaggs_SOURCES})
-SET(dcm2acr_SOURCES
- dcm2acr.cxx
-)
-ADD_EXECUTABLE(dcm2acr ${dcm2acr_SOURCES})
+CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
+ADD_EXECUTABLE(gdcmTests ${Tests})
+IF(GDCM_VTK)
+ TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
+ELSE(GDCM_VTK)
+ TARGET_LINK_LIBRARIES(gdcmTests gdcm)
+ENDIF(GDCM_VTK)
+
+SET (TestsToRun ${Tests})
+REMOVE (TestsToRun gdcmTests.cxx)
+
+# Loop over files and create executables
+FOREACH(file ${TEST_SOURCES})
+ GET_FILENAME_COMPONENT(name ${file} NAME_WE)
+# IF (GDCM_DATA_ROOT)
+# ADD_TEST(${name} ${CXX_TEST_PATH}/gdcmTests ${name}
+# -D ${GDCM_DATA_ROOT}
+# -T ${GDCM_BINARY_DIR}/Testing/Temporary
+# -V Baseline/gdcm/${name}.png)
+# ELSE (GDCM_DATA_ROOT)
+ ADD_TEST(${name} ${GDCM_TESTS} ${name})
+# ENDIF (GDCM_DATA_ROOT)
+ENDFOREACH(file ${TEST_SOURCES})
+
+#-----------------------------------------------------------------------------
+
+# We need to test the reading of all dicom images in the gdcmData directory
+# First parse this directory and extract all images
+
+# For now only *.dcm will be picked up, since there is a bug in cmake 1.8.3
+# and I don't know how to work around
+FILE(GLOB GDCM_DATA_IMAGES_GLOB
+ "${GDCM_DATA_ROOT}/*.dcm"
+# "${GDCM_DATA_ROOT}/*.acr"
+ )
+
+# This is a GLOB expression, change it into a list separated with a comma and \n
+SET(GDCM_DATA_IMAGES)
+FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
+ SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename}\",")
+ENDFOREACH(filename)
+
+# Populate GDCM_DATA_IMAGES:
+FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h.in"
+ "const char * const gdcmDataImages[] = { @GDCM_DATA_IMAGES@ \n 0 };"
+ )
+
+# Generate the header file:
+CONFIGURE_FILE(
+ ${GDCM_BINARY_DIR}/gdcmDataImages.h.in
+ ${GDCM_BINARY_DIR}/gdcmDataImages.h
+ )