diff options
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/CMP0135/CMP0135-Common.cmake | 37 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt | 11 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/PATH_EQUAL.cmake.in | 8 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/RunCMakeTest.cmake | 14 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-stderr.txt | 42 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/check_errors.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-PATH_EQUAL/generate.cmake | 2 |
14 files changed, 141 insertions, 8 deletions
diff --git a/Tests/RunCMake/CMP0135/CMP0135-Common.cmake b/Tests/RunCMake/CMP0135/CMP0135-Common.cmake index 4b7cce5..ad60b7c 100644 --- a/Tests/RunCMake/CMP0135/CMP0135-Common.cmake +++ b/Tests/RunCMake/CMP0135/CMP0135-Common.cmake @@ -1,7 +1,8 @@ +#============================================================================== +# ExternalProject +#============================================================================== +set(stamp_dir "${CMAKE_CURRENT_BINARY_DIR}/stamps-ep") include(ExternalProject) - -set(stamp_dir "${CMAKE_CURRENT_BINARY_DIR}/stamps") - ExternalProject_Add(fake_ext_proj # We don't actually do a build, so we never try to download from this URL URL https://example.com/something.zip @@ -12,7 +13,33 @@ ExternalProject_Add(fake_ext_proj set(extraction_script "${stamp_dir}/extract-fake_ext_proj.cmake") file(STRINGS "${extraction_script}" results REGEX "--touch") if("${results}" STREQUAL "") - message(STATUS "Using timestamps from archive") + message(STATUS "ExternalProject: Using timestamps from archive") +else() + message(STATUS "ExternalProject: Using extraction time for the timestamps") +endif() + +#============================================================================== +# FetchContent +#============================================================================== +set(stamp_dir "${CMAKE_CURRENT_BINARY_DIR}/stamps-fc") +set(archive_file ${CMAKE_CURRENT_BINARY_DIR}/test_archive.7z) +file(ARCHIVE_CREATE + OUTPUT ${archive_file} + PATHS ${CMAKE_CURRENT_LIST_DIR} + FORMAT 7zip +) +include(FetchContent) +FetchContent_Declare(fake_fc_proj + URL file://${archive_file} + STAMP_DIR ${stamp_dir} +) +FetchContent_MakeAvailable(fake_fc_proj) + +# Report whether the --touch option was added to the extraction script +set(extraction_script "${stamp_dir}/extract-fake_fc_proj-populate.cmake") +file(STRINGS "${extraction_script}" results REGEX "--touch") +if("${results}" STREQUAL "") + message(STATUS "FetchContent: Using timestamps from archive") else() - message(STATUS "Using extraction time for the timestamps") + message(STATUS "FetchContent: Using extraction time for the timestamps") endif() diff --git a/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt b/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt index bf53c0b..ceef9b8 100644 --- a/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt +++ b/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt @@ -1 +1,2 @@ -Using extraction time for the timestamps +-- ExternalProject: Using extraction time for the timestamps +-- FetchContent: Using extraction time for the timestamps diff --git a/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt b/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt index ee57beb..1288c20 100644 --- a/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt +++ b/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt @@ -1 +1,2 @@ -Using timestamps from archive +-- ExternalProject: Using timestamps from archive +-- FetchContent: Using timestamps from archive diff --git a/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt b/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt index 8ba0027..6bf944e 100644 --- a/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt @@ -8,3 +8,14 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): what you want\. Update your project to the NEW behavior or specify the DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this robustness issue\. +.* +CMake Warning \(dev\) at .*/Modules/FetchContent.cmake:[0-9]+ \(message\): + The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is + not set\. The policy's OLD behavior will be used\. When using a URL + download, the timestamps of extracted files should preferably be that of + the time of extraction, otherwise code that depends on the extracted + contents might not be rebuilt if the URL changes\. The OLD behavior + preserves the timestamps from the archive instead, but this is usually not + what you want\. Update your project to the NEW behavior or specify the + DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this + robustness issue\. diff --git a/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt b/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt index ee57beb..1288c20 100644 --- a/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt +++ b/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt @@ -1 +1,2 @@ -Using timestamps from archive +-- ExternalProject: Using timestamps from archive +-- FetchContent: Using timestamps from archive diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a94cf21..3ca01ec 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -331,6 +331,7 @@ add_RunCMake_test(GenEx-TARGET_FILE -DLINKER_SUPPORTS_PDB=${LINKER_SUPPORTS_PDB} add_RunCMake_test(GenEx-GENEX_EVAL) add_RunCMake_test(GenEx-TARGET_RUNTIME_DLLS) add_RunCMake_test(GenEx-PATH) +add_RunCMake_test(GenEx-PATH_EQUAL) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorInstance) add_RunCMake_test(GeneratorPlatform) diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/CMakeLists.txt b/Tests/RunCMake/GenEx-PATH_EQUAL/CMakeLists.txt new file mode 100644 index 0000000..f9748e9 --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.18...3.24) + +project(${RunCMake_TEST} NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/PATH_EQUAL.cmake.in b/Tests/RunCMake/GenEx-PATH_EQUAL/PATH_EQUAL.cmake.in new file mode 100644 index 0000000..e8a1e95 --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/PATH_EQUAL.cmake.in @@ -0,0 +1,8 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") + +expect_true("$<PATH_EQUAL:a///b/c,a/b/c>" "a///b/c" "a/b/c") + +expect_false("$<PATH_EQUAL:a/b/d/../c,a/b/c>" "a/b/d/../c" "a/b/c") + +expect_true("$<PATH_EQUAL:$<PATH:NORMAL_PATH,a/b/d/../c>,a/b/c>" "a/b/d/../c" "a/b/c") diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-PATH_EQUAL/RunCMakeTest.cmake new file mode 100644 index 0000000..802c503 --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/RunCMakeTest.cmake @@ -0,0 +1,14 @@ + +include(RunCMake) + +run_cmake(WrongArguments) + +function(check_path_execution name) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_VARIANT_DESCRIPTION " - ${name}") + run_cmake_with_options(generate -DPATH_TEST=${name}) + run_cmake_command(check "${CMAKE_COMMAND}" "-DRunCMake_SOURCE_DIR=${RunCMake_SOURCE_DIR}" -P "${RunCMake_TEST_BINARY_DIR}/${name}.cmake") +endfunction() + +check_path_execution (PATH_EQUAL) diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-result.txt b/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-stderr.txt b/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-stderr.txt new file mode 100644 index 0000000..4cbc7ba --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments-stderr.txt @@ -0,0 +1,42 @@ +CMake Error at WrongArguments.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<PATH_EQUAL> + + \$<PATH_EQUAL> expression requires 2 comma separated parameters, but got 0 + instead. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongArguments.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<PATH_EQUAL:> + + \$<PATH_EQUAL> expression requires 2 comma separated parameters, but got 1 + instead. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongArguments.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<PATH_EQUAL:,,> + + \$<PATH_EQUAL> expression requires 2 comma separated parameters, but got 3 + instead. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongArguments.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<PATH_EQUAL:something,,> + + \$<PATH_EQUAL> expression requires 2 comma separated parameters, but got 3 + instead. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments.cmake b/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments.cmake new file mode 100644 index 0000000..1288a0e --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/WrongArguments.cmake @@ -0,0 +1,7 @@ + +add_custom_target(check ALL COMMAND check + $<PATH_EQUAL> + $<PATH_EQUAL:> + $<PATH_EQUAL:,,> + $<PATH_EQUAL:something,,> + VERBATIM) diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/check_errors.cmake b/Tests/RunCMake/GenEx-PATH_EQUAL/check_errors.cmake new file mode 100644 index 0000000..fd99eb4 --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/check_errors.cmake @@ -0,0 +1,12 @@ + +function(EXPECT_TRUE output data reference) + if (NOT output) + message(SEND_ERROR "'${data}' not equal to '${reference}'") + endif() +endfunction() + +function(EXPECT_FALSE output data reference) + if (output) + message(SEND_ERROR "'${data}' equal to '${reference}'") + endif() +endfunction() diff --git a/Tests/RunCMake/GenEx-PATH_EQUAL/generate.cmake b/Tests/RunCMake/GenEx-PATH_EQUAL/generate.cmake new file mode 100644 index 0000000..4bd5f3b --- /dev/null +++ b/Tests/RunCMake/GenEx-PATH_EQUAL/generate.cmake @@ -0,0 +1,2 @@ + +file(GENERATE OUTPUT "${PATH_TEST}.cmake" INPUT "${PATH_TEST}.cmake.in") |