diff options
author | Cristian Le <git@lecris.dev> | 2024-01-03 19:34:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-01-09 21:36:55 (GMT) |
commit | fa00928bcded97d20c9aa2813f68f1df41591125 (patch) | |
tree | c84c88485c075b94d2f92d3e6467fb776a217f41 /Tests | |
parent | ff0085cf74eb10a7e5f9c906258022c6b8b68413 (diff) | |
download | CMake-fa00928bcded97d20c9aa2813f68f1df41591125.zip CMake-fa00928bcded97d20c9aa2813f68f1df41591125.tar.gz CMake-fa00928bcded97d20c9aa2813f68f1df41591125.tar.bz2 |
file: `STRINGS` + `REGEX` store match results
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-Common.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-NEW-stdout.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-NEW.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-OLD-stdout.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-OLD.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-WARN-stderr.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-WARN-stdout.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159-WARN.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMP0159.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-STRINGS/RunCMakeTest.cmake | 5 |
13 files changed, 62 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a4e4800..7f58ceb 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -538,6 +538,7 @@ foreach(var endforeach() add_RunCMake_test(file-DOWNLOAD) add_RunCMake_test(file-RPATH -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(file-STRINGS) add_RunCMake_test(find_file -DMINGW=${MINGW}) add_RunCMake_test(find_library -DMINGW=${MINGW} -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DMSVC=${MSVC}) add_RunCMake_test(find_package -DMINGW=${MINGW} -DMSYS=${MSYS}) diff --git a/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake b/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake index 4107aa4..ef08627 100644 --- a/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake +++ b/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake @@ -1,2 +1,3 @@ cmake_policy(VERSION 3.24) +cmake_policy(SET CMP0159 NEW) enable_language(C) diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-Common.cmake b/Tests/RunCMake/file-STRINGS/CMP0159-Common.cmake new file mode 100644 index 0000000..3608882 --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-Common.cmake @@ -0,0 +1,12 @@ +function (output_results msg) + message(STATUS "results from: ${msg}") + message(STATUS "CMAKE_MATCH_0: -->${CMAKE_MATCH_0}<--") + message(STATUS "CMAKE_MATCH_1: -->${CMAKE_MATCH_1}<--") + message(STATUS "CMAKE_MATCH_2: -->${CMAKE_MATCH_2}<--") + message(STATUS "CMAKE_MATCH_COUNT: -->${CMAKE_MATCH_COUNT}<--") +endfunction () + +# Populate `CMAKE_MATCH_<n>` with some initial value +string(REGEX MATCH "(.*):" _ "Initial-value:") +file(STRINGS CMP0159.txt _ REGEX "(.*): (.*)") +output_results(CMP0159) diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-NEW-stdout.txt b/Tests/RunCMake/file-STRINGS/CMP0159-NEW-stdout.txt new file mode 100644 index 0000000..f163622 --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-NEW-stdout.txt @@ -0,0 +1,5 @@ +-- results from: CMP0159 +-- CMAKE_MATCH_0: -->real-value: 1<-- +-- CMAKE_MATCH_1: -->real-value<-- +-- CMAKE_MATCH_2: -->1<-- +-- CMAKE_MATCH_COUNT: -->2<-- diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-NEW.cmake b/Tests/RunCMake/file-STRINGS/CMP0159-NEW.cmake new file mode 100644 index 0000000..8617561 --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0159 NEW) + +include(CMP0159-Common.cmake) diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-OLD-stdout.txt b/Tests/RunCMake/file-STRINGS/CMP0159-OLD-stdout.txt new file mode 100644 index 0000000..16ee678 --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-OLD-stdout.txt @@ -0,0 +1,5 @@ +-- results from: CMP0159 +-- CMAKE_MATCH_0: -->Initial-value:<-- +-- CMAKE_MATCH_1: -->Initial-value<-- +-- CMAKE_MATCH_2: --><-- +-- CMAKE_MATCH_COUNT: -->1<-- diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-OLD.cmake b/Tests/RunCMake/file-STRINGS/CMP0159-OLD.cmake new file mode 100644 index 0000000..4137aea --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0159 OLD) + +include(CMP0159-Common.cmake) diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-WARN-stderr.txt b/Tests/RunCMake/file-STRINGS/CMP0159-WARN-stderr.txt new file mode 100644 index 0000000..e82486c --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-WARN-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at CMP0159-Common.cmake:[0-9]+ \(file\): + Policy CMP0159 is not set: file\(STRINGS\) with REGEX updates + CMAKE_MATCH_<n>\. Run "cmake --help-policy CMP0159" for policy details\. + Use the cmake_policy command to set the policy and suppress this warning\. + + For compatibility, CMake is leaving CMAKE_MATCH_<n> unchanged\. +Call Stack \(most recent call first\): + CMP0159-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-WARN-stdout.txt b/Tests/RunCMake/file-STRINGS/CMP0159-WARN-stdout.txt new file mode 100644 index 0000000..16ee678 --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-WARN-stdout.txt @@ -0,0 +1,5 @@ +-- results from: CMP0159 +-- CMAKE_MATCH_0: -->Initial-value:<-- +-- CMAKE_MATCH_1: -->Initial-value<-- +-- CMAKE_MATCH_2: --><-- +-- CMAKE_MATCH_COUNT: -->1<-- diff --git a/Tests/RunCMake/file-STRINGS/CMP0159-WARN.cmake b/Tests/RunCMake/file-STRINGS/CMP0159-WARN.cmake new file mode 100644 index 0000000..1feab4b --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159-WARN.cmake @@ -0,0 +1,4 @@ + +set(CMAKE_POLICY_WARNING_CMP0159 TRUE) + +include(CMP0159-Common.cmake) diff --git a/Tests/RunCMake/file-STRINGS/CMP0159.txt b/Tests/RunCMake/file-STRINGS/CMP0159.txt new file mode 100644 index 0000000..4b31aed --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMP0159.txt @@ -0,0 +1,3 @@ +overwritten-value: -1 +real-value: 1 +ignored = -2 diff --git a/Tests/RunCMake/file-STRINGS/CMakeLists.txt b/Tests/RunCMake/file-STRINGS/CMakeLists.txt new file mode 100644 index 0000000..9a66cde --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.13) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/file-STRINGS/RunCMakeTest.cmake b/Tests/RunCMake/file-STRINGS/RunCMakeTest.cmake new file mode 100644 index 0000000..a22b3d8 --- /dev/null +++ b/Tests/RunCMake/file-STRINGS/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0159-WARN) +run_cmake(CMP0159-OLD) +run_cmake(CMP0159-NEW) |