1get_filename_component(_VTKExternalData_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
2include(${_VTKExternalData_DIR}/ExternalData.cmake)
3
4if(NOT VTK_DATA_STORE)
5  # Select a default from the following.
6  set(VTK_DATA_STORE_DEFAULT "")
7  if(EXISTS "${VTK_SOURCE_DIR}/.ExternalData/config/store")
8    # Configuration left by developer setup script.
9    file(STRINGS "${VTK_SOURCE_DIR}/.ExternalData/config/store"
10      VTK_DATA_STORE_DEFAULT LIMIT_COUNT 1 LIMIT_INPUT 1024)
11  elseif(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/../VTKExternalData")
12    # Adjacent directory created by user.
13    get_filename_component(VTK_DATA_STORE_DEFAULT
14      "${CMAKE_SOURCE_DIR}/../VTKExternalData" ABSOLUTE)
15  elseif(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/../ExternalData")
16    # Generic adjacent directory created by user.
17    get_filename_component(VTK_DATA_STORE_DEFAULT
18      "${CMAKE_SOURCE_DIR}/../ExternalData" ABSOLUTE)
19  elseif(DEFINED "ENV{VTKExternalData_OBJECT_STORES}")
20    # The VTKExternalData environment variable.
21    file(TO_CMAKE_PATH "$ENV{VTKExternalData_OBJECT_STORES}" VTK_DATA_STORE_DEFAULT)
22  elseif(DEFINED "ENV{ExternalData_OBJECT_STORES}")
23    # Generic ExternalData environment variable.
24    file(TO_CMAKE_PATH "$ENV{ExternalData_OBJECT_STORES}" VTK_DATA_STORE_DEFAULT)
25  endif()
26endif()
27
28# Provide users with an option to select a local object store,
29# starting with the above-selected default.
30set(VTK_DATA_STORE "${VTK_DATA_STORE_DEFAULT}" CACHE PATH
31  "Local directory holding ExternalData objects in the layout %(algo)/%(hash).")
32mark_as_advanced(VTK_DATA_STORE)
33
34# Use a store in the build tree if none is otherwise configured.
35if(NOT VTK_DATA_STORE)
36  if(ExternalData_OBJECT_STORES)
37    set(VTK_DATA_STORE "")
38  else()
39    set(VTK_DATA_STORE "${CMAKE_BINARY_DIR}/ExternalData/Objects")
40    file(MAKE_DIRECTORY "${VTK_DATA_STORE}")
41  endif()
42endif()
43
44# Tell ExternalData module about selected object stores.
45list(APPEND ExternalData_OBJECT_STORES
46  # Store selected by VTK-specific configuration above.
47  ${VTK_DATA_STORE}
48
49  # Local data store populated by the VTK pre-commit hook
50  "${CMAKE_SOURCE_DIR}/.ExternalData"
51  )
52
53set(ExternalData_BINARY_ROOT ${CMAKE_BINARY_DIR}/ExternalData)
54
55set(ExternalData_URL_TEMPLATES "" CACHE STRING
56  "Additional URL templates for the ExternalData CMake script to look for testing data. E.g.
57file:///var/bigharddrive/%(algo)/%(hash)")
58mark_as_advanced(ExternalData_URL_TEMPLATES)
59list(APPEND ExternalData_URL_TEMPLATES
60  # Data published by MIDAS
61  "http://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=%(hash)&algorithm=%(algo)"
62
63  # Data published by developers using git-gerrit-push.
64  "http://www.vtk.org/files/ExternalData/%(algo)/%(hash)"
65  )
66
67# Tell ExternalData commands to transform raw files to content links.
68# TODO: Condition this feature on presence of our pre-commit hook.
69set(ExternalData_LINK_CONTENT MD5)
70
71# Match series of the form <base>.<ext>, <base>_<n>.<ext> such that <base> may
72# end in a (test) number that is not part of any series numbering.
73set(ExternalData_SERIES_PARSE "()(\\.[^./]*)$")
74set(ExternalData_SERIES_MATCH "(_[0-9]+)?")
75
76if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST})
77  # Dashboard builds always need data.
78  set(VTK_DATA_EXCLUDE_FROM_ALL OFF)
79endif()
80
81if(NOT DEFINED VTK_DATA_EXCLUDE_FROM_ALL)
82  if(EXISTS "${VTK_SOURCE_DIR}/.ExternalData/config/exclude-from-all")
83    # Configuration left by developer setup script.
84    file(STRINGS "${VTK_SOURCE_DIR}/.ExternalData/config/exclude-from-all"
85      VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT LIMIT_COUNT 1 LIMIT_INPUT 1024)
86  elseif(DEFINED "ENV{VTK_DATA_EXCLUDE_FROM_ALL}")
87    set(VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT
88      "$ENV{VTK_DATA_EXCLUDE_FROM_ALL}")
89  else()
90    set(VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT OFF)
91  endif()
92  set(VTK_DATA_EXCLUDE_FROM_ALL "${VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT}"
93    CACHE BOOL "Exclude test data download from default 'all' target."
94    )
95  mark_as_advanced(VTK_DATA_EXCLUDE_FROM_ALL)
96endif()
97