mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
ExternalData: Add support for custom algorithm-to-URL mapping
Allow URL templates to contain a %(algo:<key>) placeholder that is replaced by mapping the canonical hash algorithm name through a map defined by the <key>. Extend the Module.ExternalData test to cover the behavior. Extend the RunCMake.ExternalData test to cover error cases.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DataAlgoMap
|
||||
@@ -0,0 +1 @@
|
||||
DataAlgoMap
|
||||
@@ -10,8 +10,10 @@ if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
|
||||
endif()
|
||||
set(ExternalData_URL_TEMPLATES
|
||||
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
|
||||
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/Alt/%(algo:MyAlgoMap1)/%(hash)"
|
||||
"ExternalDataCustomScript://MyScript1/%(algo)/%(hash)"
|
||||
)
|
||||
set(ExternalData_URL_ALGO_MD5_MyAlgoMap1 MyAlgoMap1-md5)
|
||||
set(ExternalData_CUSTOM_SCRIPT_MyScript1 "${CMAKE_CURRENT_SOURCE_DIR}/MyScript1.cmake")
|
||||
set(ExternalData_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ExternalData")
|
||||
file(REMOVE_RECURSE ${ExternalData_BINARY_ROOT}) # clean test
|
||||
@@ -26,6 +28,8 @@ ExternalData_Add_Test(Data1
|
||||
-D Data=DATA{Data.dat}
|
||||
${Data1CheckSpaces}
|
||||
-D DataScript=DATA{DataScript.dat}
|
||||
-D DataAlgoMapA=DATA{DataAlgoMapA.dat}
|
||||
-D DataAlgoMapB=DATA{DataAlgoMapB.dat}
|
||||
-D DataMissing=DATA{DataMissing.dat}
|
||||
-D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat}
|
||||
-D SeriesA=DATA{SeriesA.dat,:}
|
||||
|
||||
@@ -12,6 +12,14 @@ file(STRINGS "${DataScript}" lines LIMIT_INPUT 1024)
|
||||
if(NOT "x${lines}" STREQUAL "xDataScript")
|
||||
message(SEND_ERROR "Input file:\n ${DataScript}\ndoes not have expected content, but [[${lines}]]")
|
||||
endif()
|
||||
file(STRINGS "${DataAlgoMapA}" lines LIMIT_INPUT 1024)
|
||||
if(NOT "x${lines}" STREQUAL "xDataAlgoMap")
|
||||
message(SEND_ERROR "Input file:\n ${DataAlgoMapA}\ndoes not have expected content, but [[${lines}]]")
|
||||
endif()
|
||||
file(STRINGS "${DataAlgoMapB}" lines LIMIT_INPUT 1024)
|
||||
if(NOT "x${lines}" STREQUAL "xDataAlgoMap")
|
||||
message(SEND_ERROR "Input file:\n ${DataAlgoMapB}\ndoes not have expected content, but [[${lines}]]")
|
||||
endif()
|
||||
if(DataMissing)
|
||||
if(EXISTS "${DataMissing}")
|
||||
message(SEND_ERROR
|
||||
|
||||
1
Tests/Module/ExternalData/DataAlgoMapA.dat.md5
Normal file
1
Tests/Module/ExternalData/DataAlgoMapA.dat.md5
Normal file
@@ -0,0 +1 @@
|
||||
dded55e43cd6529ee35d24113dfc87a3
|
||||
1
Tests/Module/ExternalData/DataAlgoMapB.dat.sha1
Normal file
1
Tests/Module/ExternalData/DataAlgoMapB.dat.sha1
Normal file
@@ -0,0 +1 @@
|
||||
85158f0c1996837976e858c42a9a7634bfe91b93
|
||||
Reference in New Issue
Block a user