diff options
author | Brad King <brad.king@kitware.com> | 2013-01-30 19:44:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-01-30 19:55:12 (GMT) |
commit | e2e0d2e3c7108d5ce41f032ad9089155c6b4735c (patch) | |
tree | 35f65eec3eb7fa5c739f19cee30a44f94e1decb1 | |
parent | ee2abfdc8913e4e9a5bc77c56a9d3dea83fde6f1 (diff) | |
download | CMake-e2e0d2e3c7108d5ce41f032ad9089155c6b4735c.zip CMake-e2e0d2e3c7108d5ce41f032ad9089155c6b4735c.tar.gz CMake-e2e0d2e3c7108d5ce41f032ad9089155c6b4735c.tar.bz2 |
ExternalData: Collapse ../ components in DATA{} paths
Relative path components need to be normalized out even if they appear
in the middle of a caller-supplied string.
-rw-r--r-- | Modules/ExternalData.cmake | 3 | ||||
-rw-r--r-- | Tests/Module/ExternalData/Data2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/Module/ExternalData/Data2/Data2Check.cmake | 9 | ||||
-rw-r--r-- | Tests/Module/ExternalData/Data2b.dat.md5 | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt | 12 |
6 files changed, 23 insertions, 6 deletions
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 26b0f99..825b7b8 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -334,8 +334,9 @@ function(_ExternalData_arg target arg options var_file) if(IS_ABSOLUTE "${data}") set(absdata "${data}") else() - get_filename_component(absdata "${CMAKE_CURRENT_SOURCE_DIR}/${data}" ABSOLUTE) + set(absdata "${CMAKE_CURRENT_SOURCE_DIR}/${data}") endif() + get_filename_component(absdata "${absdata}" ABSOLUTE) # Convert to relative path under the source tree. if(NOT ExternalData_SOURCE_ROOT) diff --git a/Tests/Module/ExternalData/Data2/CMakeLists.txt b/Tests/Module/ExternalData/Data2/CMakeLists.txt index e6d8767..c5b79ac 100644 --- a/Tests/Module/ExternalData/Data2/CMakeLists.txt +++ b/Tests/Module/ExternalData/Data2/CMakeLists.txt @@ -4,6 +4,7 @@ ExternalData_Add_Test(Data2 NAME Data2Check COMMAND ${CMAKE_COMMAND} -D Data2=DATA{../Data2.dat} + -D Data2b=DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data2b.dat} -D SeriesC=DATA{SeriesC_1_.my.dat,:} -P ${CMAKE_CURRENT_SOURCE_DIR}/Data2Check.cmake ) diff --git a/Tests/Module/ExternalData/Data2/Data2Check.cmake b/Tests/Module/ExternalData/Data2/Data2Check.cmake index a1dd509..d5b0c7b 100644 --- a/Tests/Module/ExternalData/Data2/Data2Check.cmake +++ b/Tests/Module/ExternalData/Data2/Data2Check.cmake @@ -1,6 +1,9 @@ -if(NOT EXISTS "${Data2}") - message(SEND_ERROR "Input file:\n ${Data2}\ndoes not exist!") -endif() +foreach(d "${Data2}" "${Data2b}") + file(STRINGS "${d}" lines LIMIT_INPUT 1024) + if(NOT "x${lines}" STREQUAL "xInput file already transformed.") + message(SEND_ERROR "Input file:\n ${d}\ndoes not have expected content, but [[${lines}]]") + endif() +endforeach() foreach(n 1 2 3) string(REGEX REPLACE "_1_\\.my\\.dat$" "_${n}_.my.dat" SeriesCFile "${SeriesC}") if(NOT EXISTS "${SeriesCFile}") diff --git a/Tests/Module/ExternalData/Data2b.dat.md5 b/Tests/Module/ExternalData/Data2b.dat.md5 new file mode 100644 index 0000000..70e39bd --- /dev/null +++ b/Tests/Module/ExternalData/Data2b.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt index 35a8cc1..03924cb 100644 --- a/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt +++ b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt @@ -1,2 +1,3 @@ --- Data reference correctly transformed in parent dir! +-- Data reference correctly transformed in parent dir 1! +-- Data reference correctly transformed in parent dir 2! -- Data reference correctly transformed in current dir! diff --git a/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt index 0782460..881ff5c 100644 --- a/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt +++ b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt @@ -2,7 +2,17 @@ set(input ../Data.txt) set(output ${CMAKE_BINARY_DIR}/Data.txt) ExternalData_Expand_Arguments(Data args DATA{${input}}) if("x${args}" STREQUAL "x${output}") - message(STATUS "Data reference correctly transformed in parent dir!") + message(STATUS "Data reference correctly transformed in parent dir 1!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() + +set(input ${CMAKE_CURRENT_SOURCE_DIR}/../Data.txt) +set(output ${CMAKE_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed in parent dir 2!") else() message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" "but we expected:\n ${output}") |