IF(NOT BTK_TESTING_DATA_PATH)
  MESSAGE(SEND_ERROR "You need to set the variable BTK_TESTING_DATA_PATH to check if all the required C3D file are available for the unit tests.")
ELSE(NOT BTK_TESTING_DATA_PATH)
  SET(URL "ftp://c3dftp:c3dftp@ftp.c3d.org/data/")
  SET(C3DSamples "${BTK_TESTING_DATA_PATH}/Input/C3DSamples")
  SET(C3DDL_GLOBAL_MSG 0)
  MACRO(C3DDL filename)
    IF(NOT EXISTS "${C3DSamples}/${filename}")
      IF(NOT C3DDL_GLOBAL_MSG)
        MESSAGE(STATUS "Downloading C3D samples from ftp.c3d.org")
        SET(C3DDL_GLOBAL_MSG 1)
      ENDIF(NOT C3DDL_GLOBAL_MSG)
      MESSAGE(STATUS " - Downloading ${filename} ...")
      FILE(DOWNLOAD "${URL}/${filename}" "${C3DSamples}/${filename}" STATUS C3DDL_STATUS)
      LIST(GET C3DDL_STATUS 0 C3DDL_STATUS_CODE)
      SET(C3DDL_STATUS_MSG "OK")
      IF(C3DDL_STATUS_CODE)
        LIST(GET C3DDL_STATUS 1 C3DDL_STATUS_MSG)
        FILE(REMOVE "${C3DSamples}/${filename}")
      ENDIF(C3DDL_STATUS_CODE)
      MESSAGE(STATUS " - Downloading ${filename} ... ${C3DDL_STATUS_MSG}")
    ENDIF(NOT EXISTS "${C3DSamples}/${filename}")
  ENDMACRO(C3DDL)
  # Sample 01
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample01")
  C3DDL("sample01/Eb015pi.c3d")
  C3DDL("sample01/Eb015pr.c3d")
  C3DDL("sample01/Eb015si.c3d")
  C3DDL("sample01/Eb015sr.c3d")
  C3DDL("sample01/Eb015vi.c3d")
  C3DDL("sample01/Eb015vr.c3d")
  C3DDL("sample01/readme.txt")
  # Sample 02
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample02")
  C3DDL("sample02/DEC_INT.C3D")
  C3DDL("sample02/Dec_real.c3d")
  C3DDL("sample02/pc_int.c3d")
  C3DDL("sample02/pc_real.c3d")
  C3DDL("sample02/sgi_int.c3d")
  C3DDL("sample02/sgi_real.c3d")
  C3DDL("sample02/readme.txt")
  # Sample 04
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample04")
  C3DDL("sample04/sub_labels.c3d")
  C3DDL("sample04/readme.txt")
  # Sample 05
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample05")
  C3DDL("sample05/vicon512.c3d")
  C3DDL("sample05/readme.txt")
  # Sample 05
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample06")
  C3DDL("sample06/MACsample.c3d")
  C3DDL("sample06/readme.txt")
  # Sample 08
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample08")
  C3DDL("sample08/TESTAPI.c3d")
  C3DDL("sample08/TESTBPI.c3d")
  C3DDL("sample08/TESTCPI.c3d")
  C3DDL("sample08/TESTDPI.c3d")
  C3DDL("sample08/readme.txt")
  # Sample 09
  C3DDL("sample09/PlugInC3D.c3d")
  C3DDL("sample09/readme.txt")
  # Sample 10
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample10")
  C3DDL("sample10/MATRIX.PDF")
  C3DDL("sample10/README.TXT")
  C3DDL("sample10/TYPE-2.C3D")
  C3DDL("sample10/type-2a.c3d")
  C3DDL("sample10/TYPE-4.C3D")
  C3DDL("sample10/TYPE-4.XLS")
  C3DDL("sample10/type-4a.c3d")
  # Sample 13
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample13")
  C3DDL("sample13/Dance.c3d")
  C3DDL("sample13/golfswing.c3d")
  C3DDL("sample13/readme.txt")
  # Sample 15
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample15")
  C3DDL("sample15/FP1.C3D")
  C3DDL("sample15/FP2.C3D")
  C3DDL("sample15/readme.txt")
  # Sample 18
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample18")
  C3DDL("sample18/bad_parameter_section.c3d")
  C3DDL("sample18/readme.txt")
  # Sample 19
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample19")
  C3DDL("sample19/sample19.c3d")
  C3DDL("sample19/readme.txt")
  # Sample 20
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample20")
  C3DDL("sample20/phasespace.txt")
  C3DDL("sample20/phasespace_sample.c3d")
  # Sample 21
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample21")
  C3DDL("sample21/sample21.c3d")
  C3DDL("sample21/sample21.txt")
  # Sample 22
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample22")
  C3DDL("sample22/BKINtechnologies.c3d")
  C3DDL("sample22/sample22.txt")
  # Sample 24
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample24")
  C3DDL("sample24/MotionMonitorC3D.c3d")
  C3DDL("sample24/readme.txt")
  # Sample 28
  FILE(MAKE_DIRECTORY "${C3DSamples}/sample28")
  C3DDL("sample28/dynamic.C3D")
  C3DDL("sample28/readme.txt")
  C3DDL("sample28/standing.C3D")
  C3DDL("sample28/type1.C3D")
ENDIF(NOT BTK_TESTING_DATA_PATH)