+CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
+ADD_EXECUTABLE(gdcmTests ${Tests})
+IF(GDCM_VTK)
+ IF(GDCM_DATA_ROOT)
+ TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
+ ELSE(GDCM_DATA_ROOT)
+ TARGET_LINK_LIBRARIES(gdcmTests gdcm)
+ ENDIF(GDCM_DATA_ROOT)
+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)
+ ADD_TEST(${name} ${GDCM_TESTS} ${name})
+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
+
+FILE(GLOB GDCM_DATA_IMAGES_GLOB
+ "${GDCM_DATA_ROOT}/*.acr"
+ "${GDCM_DATA_ROOT}/*.dcm"
+ "${GDCM_DATA_ROOT}/*.nema"
+ "${GDCM_DATA_ROOT}/*.ima"
+ )
+
+# Black list of images known to break lots of readers (efilm, xmedcon ...):
+SET(BLACK_LIST
+ # Multiframe Papyrus format image
+ # Just to remember this format exists, and is gdcm::File compliant
+ # (NOT gdcm::FileHelper ...)
+ # any contribution is welcome
+ "PET-cardio-Multiframe-Papyrus.dcm"
+ # From David Clunie's Compresion Dataset
+ "D_CLUNIE_CT1_JLSN.dcm"
+ "D_CLUNIE_CT1_JLSL.dcm"
+ #Not a Dicom Image, but a RT Object
+ "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm"
+ #Dicom MPEG image
+ "ETIAM_video_002.dcm"
+ #Something stupid occured in the code for LibIDO images.
+ #I Black list them for a while. JP
+ #"gdcm-ACR-LibIDO.acr"
+ "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
+ #16 Bits per pixel images with LUT 16 Bits.
+ #I wait to be 100% sure before releasing them. JP
+ "rle16sti.dcm"
+ "rle16loo.dcm"
+ # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
+ # but then it breaks other images...
+ "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
+ #
+ # ------------
+ #
+ #Still cause troubles (see the .README.txt file for more details)
+ "MR_Philips_Intera_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"
+ "MR_Philips_Intera_PrivateSequenceExplicitVR.dcm"
+ #The 2 previous images are identical !
+ #--> Replaced by more significant name
+ "MR_Philips_Intera_PrivateSequenceExplicitVR_in_SQ_2001_e05f_item_wrong_lgt_use_NOSHADOWSEQ.dcm"
+
+ #hexedit shows something *very* strange around offset 0x76e !
+ #the images looks *over*corrupted (on disc, not from the manufacturer!)
+ "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
+
+ # Seems this one hangs on 64 bits processors ?!?
+ # I blacklist it untill the pb is solved.
+ # (to get some more green on the Dasboards)
+ "MR_Philips-Intera_BreaksNOSHADOW.dcm"
+ )
+
+# Create a specific list of dicom files that we know are part of a sequence
+SET(SEQ_LIST
+ "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
+ )
+
+# Add a special test that requires dciodvfy from dicom3tools
+INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
+
+# This is a GLOB expression, change it into a list separated with a comma and \n
+SET(GDCM_DATA_IMAGES)
+SET(GDCM_DATA_SEQ_IMAGES)
+FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
+ GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
+ IF(DCIODVFY_FOUND)
+ ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
+ ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
+ ENDIF(DCIODVFY_FOUND)
+ STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
+ IF(NOT bad_dicom)
+ SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
+ # SEQ_LIST is a regular expression:
+ STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
+ IF(is_seq)
+ SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
+ ENDIF(is_seq)
+ ENDIF(NOT bad_dicom)
+ENDFOREACH(filename)
+
+# Populate GDCM_DATA_IMAGES:
+FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
+ "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n"