| 1 |
include(ExternalData) |
| 2 |
set(ExternalData_LINK_CONTENT MD5) |
| 3 |
set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR}) |
| 4 |
set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData) |
| 5 |
set(input ${CMAKE_CURRENT_BINARY_DIR}/Dir) |
| 6 |
set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/Dir) |
| 7 |
set(staged "${input}/.ExternalData_MD5_c18ff9804c8deec9eaeb17063cda8b7b") |
| 8 |
set(content "To be transformed into a content link.") |
| 9 |
file(REMOVE ${staged}) |
| 10 |
file(REMOVE_RECURSE ${input}) |
| 11 |
file(WRITE ${input}/ToLink.txt "${content}") |
| 12 |
ExternalData_Expand_Arguments(Data args "DATA{${input}/,REGEX:.*}") |
| 13 |
if("x${args}" STREQUAL "x${output}") |
| 14 |
message(STATUS "Raw data correctly transformed to content link!") |
| 15 |
else() |
| 16 |
message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" |
| 17 |
"but we expected:\n ${output}") |
| 18 |
endif() |
| 19 |
if(EXISTS "${staged}") |
| 20 |
message(STATUS "Staged content exists!") |
| 21 |
else() |
| 22 |
message(FATAL_ERROR "Staged content missing!") |
| 23 |
endif() |
| 24 |
|
| 25 |
# Expand again to check whether staged content is ignored. |
| 26 |
ExternalData_Expand_Arguments(Data args "DATA{${input}/,REGEX:.*}") |
| 27 |
file(STRINGS "${staged}" staged_content LIMIT_INPUT 1024) |
| 28 |
if("${content}" STREQUAL "${staged_content}") |
| 29 |
message(STATUS "Staged content is correct!") |
| 30 |
else() |
| 31 |
message(STATUS "Staged content is incorrect!") |
| 32 |
endif() |
| 33 |
if(EXISTS "${staged}.md5") |
| 34 |
message(FATAL_ERROR "Staged content was incorrectly re-staged!") |
| 35 |
else() |
| 36 |
message(STATUS "Staged content was correctly not re-staged!") |
| 37 |
endif() |