summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalData.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-17 13:31:41 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-17 13:45:09 (GMT)
commitccd29b9af849316a9361ceb8d0addb24e7158382 (patch)
tree7375d552f4c19075a7191ef4010a462fd3724c00 /Modules/ExternalData.cmake
parentfd8bb3427858017754d5b08a2eb1f57116feebb6 (diff)
downloadCMake-ccd29b9af849316a9361ceb8d0addb24e7158382.zip
CMake-ccd29b9af849316a9361ceb8d0addb24e7158382.tar.gz
CMake-ccd29b9af849316a9361ceb8d0addb24e7158382.tar.bz2
ExternalData: Warn on missing file instead of failing
When the primary source tree path named by a DATA{} reference does not exist, produce an AUTHOR_WARNING instead of a FATAL_ERROR. This is useful when writing a new DATA{} reference to a test reference output that has not been created yet. This way the developer can run the test, manually verify the output, and then copy it into place to provide the reference and eliminate the warning. If the named source tree path is expected to be a file but exists as a directory, we still need to produce a FATAL_ERROR.
Diffstat (limited to 'Modules/ExternalData.cmake')
-rw-r--r--Modules/ExternalData.cmake44
1 files changed, 29 insertions, 15 deletions
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index ee20693..73a4990 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -421,6 +421,7 @@ function(_ExternalData_arg target arg options var_file)
set(external "") # Entries external to the source tree.
set(internal "") # Entries internal to the source tree.
set(have_original ${data_is_directory})
+ set(have_original_as_dir 0)
# Process options.
set(series_option "")
@@ -470,11 +471,18 @@ function(_ExternalData_arg target arg options var_file)
endif()
if(NOT have_original)
- message(FATAL_ERROR "Data file referenced by argument\n"
+ if(have_original_as_dir)
+ set(msg_kind FATAL_ERROR)
+ set(msg "that is directory instead of a file!")
+ else()
+ set(msg_kind AUTHOR_WARNING)
+ set(msg "that does not exist as a file (with or without an extension)!")
+ endif()
+ message(${msg_kind} "Data file referenced by argument\n"
" ${arg}\n"
"corresponds to source tree path\n"
" ${reldata}\n"
- "that does not exist as a file (with or without an extension)!")
+ "${msg}")
endif()
if(external)
@@ -591,27 +599,33 @@ function(_ExternalData_arg_find_files pattern regex)
set(alg "")
endif()
if("x${relname}" MATCHES "^x${regex}$" # matches
- AND NOT IS_DIRECTORY "${top_src}/${entry}" # not a directory
AND NOT "x${relname}" MATCHES "(^x|/)\\.ExternalData_" # not staged obj
)
- set(name "${top_src}/${relname}")
- set(file "${top_bin}/${relname}")
- if(alg)
- list(APPEND external "${file}|${name}|${alg}")
- elseif(ExternalData_LINK_CONTENT)
- _ExternalData_link_content("${name}" alg)
- list(APPEND external "${file}|${name}|${alg}")
- elseif(NOT top_same)
- list(APPEND internal "${file}|${name}")
- endif()
- if("${relname}" STREQUAL "${reldata}")
- set(have_original 1)
+ if(IS_DIRECTORY "${top_src}/${entry}")
+ if("${relname}" STREQUAL "${reldata}")
+ set(have_original_as_dir 1)
+ endif()
+ else()
+ set(name "${top_src}/${relname}")
+ set(file "${top_bin}/${relname}")
+ if(alg)
+ list(APPEND external "${file}|${name}|${alg}")
+ elseif(ExternalData_LINK_CONTENT)
+ _ExternalData_link_content("${name}" alg)
+ list(APPEND external "${file}|${name}|${alg}")
+ elseif(NOT top_same)
+ list(APPEND internal "${file}|${name}")
+ endif()
+ if("${relname}" STREQUAL "${reldata}")
+ set(have_original 1)
+ endif()
endif()
endif()
endforeach()
set(external "${external}" PARENT_SCOPE)
set(internal "${internal}" PARENT_SCOPE)
set(have_original "${have_original}" PARENT_SCOPE)
+ set(have_original_as_dir "${have_original_as_dir}" PARENT_SCOPE)
endfunction()
#-----------------------------------------------------------------------------