Merge topic 'ExternalData-missing-not-fatal'
ccd29b9a
ExternalData: Warn on missing file instead of failing
This commit is contained in:
commit
ba83d84714
|
@ -421,6 +421,7 @@ function(_ExternalData_arg target arg options var_file)
|
||||||
set(external "") # Entries external to the source tree.
|
set(external "") # Entries external to the source tree.
|
||||||
set(internal "") # Entries internal to the source tree.
|
set(internal "") # Entries internal to the source tree.
|
||||||
set(have_original ${data_is_directory})
|
set(have_original ${data_is_directory})
|
||||||
|
set(have_original_as_dir 0)
|
||||||
|
|
||||||
# Process options.
|
# Process options.
|
||||||
set(series_option "")
|
set(series_option "")
|
||||||
|
@ -470,11 +471,18 @@ function(_ExternalData_arg target arg options var_file)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT have_original)
|
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"
|
" ${arg}\n"
|
||||||
"corresponds to source tree path\n"
|
"corresponds to source tree path\n"
|
||||||
" ${reldata}\n"
|
" ${reldata}\n"
|
||||||
"that does not exist as a file (with or without an extension)!")
|
"${msg}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(external)
|
if(external)
|
||||||
|
@ -591,9 +599,13 @@ function(_ExternalData_arg_find_files pattern regex)
|
||||||
set(alg "")
|
set(alg "")
|
||||||
endif()
|
endif()
|
||||||
if("x${relname}" MATCHES "^x${regex}$" # matches
|
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
|
AND NOT "x${relname}" MATCHES "(^x|/)\\.ExternalData_" # not staged obj
|
||||||
)
|
)
|
||||||
|
if(IS_DIRECTORY "${top_src}/${entry}")
|
||||||
|
if("${relname}" STREQUAL "${reldata}")
|
||||||
|
set(have_original_as_dir 1)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
set(name "${top_src}/${relname}")
|
set(name "${top_src}/${relname}")
|
||||||
set(file "${top_bin}/${relname}")
|
set(file "${top_bin}/${relname}")
|
||||||
if(alg)
|
if(alg)
|
||||||
|
@ -608,10 +620,12 @@ function(_ExternalData_arg_find_files pattern regex)
|
||||||
set(have_original 1)
|
set(have_original 1)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
set(external "${external}" PARENT_SCOPE)
|
set(external "${external}" PARENT_SCOPE)
|
||||||
set(internal "${internal}" PARENT_SCOPE)
|
set(internal "${internal}" PARENT_SCOPE)
|
||||||
set(have_original "${have_original}" PARENT_SCOPE)
|
set(have_original "${have_original}" PARENT_SCOPE)
|
||||||
|
set(have_original_as_dir "${have_original_as_dir}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -23,6 +23,8 @@ ExternalData_Add_Test(Data1
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-D Data=DATA{Data.dat}
|
-D Data=DATA{Data.dat}
|
||||||
${Data1CheckSpaces}
|
${Data1CheckSpaces}
|
||||||
|
-D DataMissing=DATA{DataMissing.dat}
|
||||||
|
-D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat}
|
||||||
-D SeriesA=DATA{SeriesA.dat,:}
|
-D SeriesA=DATA{SeriesA.dat,:}
|
||||||
-D SeriesB=DATA{SeriesB.dat,:}
|
-D SeriesB=DATA{SeriesB.dat,:}
|
||||||
-D SeriesC=DATA{SeriesC.dat,:}
|
-D SeriesC=DATA{SeriesC.dat,:}
|
||||||
|
|
|
@ -8,6 +8,28 @@ if(DEFINED DataSpace)
|
||||||
message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
|
message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if(DataMissing)
|
||||||
|
if(EXISTS "${DataMissing}")
|
||||||
|
message(SEND_ERROR
|
||||||
|
"Input file:\n"
|
||||||
|
" ${DataMissing}\n"
|
||||||
|
"exists but should not."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "DataMissing is not set!")
|
||||||
|
endif()
|
||||||
|
if(DataMissingWithAssociated)
|
||||||
|
if(EXISTS "${DataMissingWithAssociated}")
|
||||||
|
message(SEND_ERROR
|
||||||
|
"Input file:\n"
|
||||||
|
" ${DataMissingWithAssociated}\n"
|
||||||
|
"exists but should not."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "DataMissingWithAssociated is not set!")
|
||||||
|
endif()
|
||||||
set(SeriesAn1 "1\\.dat")
|
set(SeriesAn1 "1\\.dat")
|
||||||
set(SeriesBn1 "_1\\.dat")
|
set(SeriesBn1 "_1\\.dat")
|
||||||
set(SeriesCn1 "\\.1\\.dat")
|
set(SeriesCn1 "\\.1\\.dat")
|
||||||
|
|
|
@ -7,7 +7,7 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
||||||
|
|
||||||
Directory1
|
Directory1
|
||||||
|
|
||||||
that does not exist as a file \(with or without an extension\)!
|
that is directory instead of a file!
|
||||||
Call Stack \(most recent call first\):
|
Call Stack \(most recent call first\):
|
||||||
.*
|
.*
|
||||||
Directory1.cmake:3 \(ExternalData_Add_Test\)
|
Directory1.cmake:3 \(ExternalData_Add_Test\)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
1
|
|
|
@ -1,4 +1,4 @@
|
||||||
CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
||||||
Data file referenced by argument
|
Data file referenced by argument
|
||||||
|
|
||||||
DATA{Directory3/\*}
|
DATA{Directory3/\*}
|
||||||
|
@ -12,3 +12,4 @@ Call Stack \(most recent call first\):
|
||||||
.*
|
.*
|
||||||
Directory3.cmake:3 \(ExternalData_Add_Test\)
|
Directory3.cmake:3 \(ExternalData_Add_Test\)
|
||||||
CMakeLists.txt:3 \(include\)
|
CMakeLists.txt:3 \(include\)
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
1
|
|
|
@ -1,4 +1,4 @@
|
||||||
CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
||||||
Data file referenced by argument
|
Data file referenced by argument
|
||||||
|
|
||||||
DATA{MissingData.txt}
|
DATA{MissingData.txt}
|
||||||
|
@ -10,5 +10,6 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
||||||
that does not exist as a file \(with or without an extension\)!
|
that does not exist as a file \(with or without an extension\)!
|
||||||
Call Stack \(most recent call first\):
|
Call Stack \(most recent call first\):
|
||||||
.*
|
.*
|
||||||
MissingData.cmake:2 \(ExternalData_Add_Test\)
|
MissingData.cmake:4 \(ExternalData_Expand_Arguments\)
|
||||||
CMakeLists.txt:3 \(include\)
|
CMakeLists.txt:3 \(include\)
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
-- Missing data reference correctly transformed!
|
|
@ -1,5 +1,10 @@
|
||||||
include(ExternalData)
|
include(ExternalData)
|
||||||
ExternalData_Add_Test(Data
|
|
||||||
NAME Test
|
set(output "${CMAKE_SOURCE_DIR}/MissingData.txt")
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo DATA{MissingData.txt}
|
ExternalData_Expand_Arguments(Data args DATA{MissingData.txt})
|
||||||
)
|
if("x${args}" STREQUAL "x${output}")
|
||||||
|
message(STATUS "Missing data reference correctly transformed!")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Missing data reference transformed to:\n ${args}\n"
|
||||||
|
"but we expected:\n ${output}")
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
|
||||||
|
Data file referenced by argument
|
||||||
|
|
||||||
|
DATA{MissingData.txt,Data.txt}
|
||||||
|
|
||||||
|
corresponds to source tree path
|
||||||
|
|
||||||
|
MissingData.txt
|
||||||
|
|
||||||
|
that does not exist as a file \(with or without an extension\)!
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
.*
|
||||||
|
MissingDataWithAssociated.cmake:4 \(ExternalData_Expand_Arguments\)
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.
|
|
@ -0,0 +1 @@
|
||||||
|
-- Missing data reference correctly transformed!
|
|
@ -0,0 +1,10 @@
|
||||||
|
include(ExternalData)
|
||||||
|
|
||||||
|
set(output "${CMAKE_BINARY_DIR}/MissingData.txt")
|
||||||
|
ExternalData_Expand_Arguments(Data args DATA{MissingData.txt,Data.txt})
|
||||||
|
if("x${args}" STREQUAL "x${output}")
|
||||||
|
message(STATUS "Missing data reference correctly transformed!")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Missing data reference transformed to:\n ${args}\n"
|
||||||
|
"but we expected:\n ${output}")
|
||||||
|
endif()
|
|
@ -15,6 +15,7 @@ run_cmake(LinkContentMD5)
|
||||||
run_cmake(LinkContentSHA1)
|
run_cmake(LinkContentSHA1)
|
||||||
run_cmake(LinkDirectory1)
|
run_cmake(LinkDirectory1)
|
||||||
run_cmake(MissingData)
|
run_cmake(MissingData)
|
||||||
|
run_cmake(MissingDataWithAssociated)
|
||||||
run_cmake(NoLinkInSource)
|
run_cmake(NoLinkInSource)
|
||||||
run_cmake(NoURLTemplates)
|
run_cmake(NoURLTemplates)
|
||||||
run_cmake(NormalData1)
|
run_cmake(NormalData1)
|
||||||
|
|
Loading…
Reference in New Issue