diff options
author | Brad King <brad.king@kitware.com> | 2021-07-19 20:28:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-07-20 13:47:02 (GMT) |
commit | 144be54dd31ad1320e3efa9b2b30876dcadd590a (patch) | |
tree | dc5f0b80d11162a245e6c5b1b1c98db5f38be997 /Tests | |
parent | 4ff651eb52215ca0e1ffe5e5356b56b57913fee0 (diff) | |
download | CMake-144be54dd31ad1320e3efa9b2b30876dcadd590a.zip CMake-144be54dd31ad1320e3efa9b2b30876dcadd590a.tar.gz CMake-144be54dd31ad1320e3efa9b2b30876dcadd590a.tar.bz2 |
try_compile: Propagate CMP0126 to the generated test project
Set policy CMP0126 to the value used in the calling project.
It may affect toolchain file behavior.
Diffstat (limited to 'Tests')
11 files changed, 22 insertions, 0 deletions
diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-NEW-stderr.txt b/Tests/RunCMake/ToolchainFile/CMP0126-NEW-stderr.txt new file mode 100644 index 0000000..7b91b43 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-NEW-stderr.txt @@ -0,0 +1 @@ +^try_compile CMP0126='NEW' VAR='1' diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-NEW-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-NEW-toolchain.cmake new file mode 100644 index 0000000..2f1ec86 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-NEW-toolchain.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0126-toolchain.cmake") diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-NEW.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-NEW.cmake new file mode 100644 index 0000000..62d4df1 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0126 NEW) +enable_language(C) diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-OLD-stderr.txt b/Tests/RunCMake/ToolchainFile/CMP0126-OLD-stderr.txt new file mode 100644 index 0000000..f3c068a --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-OLD-stderr.txt @@ -0,0 +1 @@ +^try_compile CMP0126='OLD' VAR='2' diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-OLD-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-OLD-toolchain.cmake new file mode 100644 index 0000000..2f1ec86 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-OLD-toolchain.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0126-toolchain.cmake") diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-OLD.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-OLD.cmake new file mode 100644 index 0000000..ef821fe --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0126 OLD) +enable_language(C) diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-WARN-stderr.txt b/Tests/RunCMake/ToolchainFile/CMP0126-WARN-stderr.txt new file mode 100644 index 0000000..f3c068a --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-WARN-stderr.txt @@ -0,0 +1 @@ +^try_compile CMP0126='OLD' VAR='2' diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-WARN-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-WARN-toolchain.cmake new file mode 100644 index 0000000..2f1ec86 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-WARN-toolchain.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0126-toolchain.cmake") diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-WARN.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-WARN.cmake new file mode 100644 index 0000000..426e2b1 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-WARN.cmake @@ -0,0 +1,2 @@ +# leave CMP0126 unset +enable_language(C) diff --git a/Tests/RunCMake/ToolchainFile/CMP0126-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CMP0126-toolchain.cmake new file mode 100644 index 0000000..d5af14f --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMP0126-toolchain.cmake @@ -0,0 +1,7 @@ +get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) +if(_IN_TC) + cmake_policy(GET CMP0126 cmp0126) + set(VAR 1) + set(VAR 2 CACHE STRING "") + message("try_compile CMP0126='${cmp0126}' VAR='${VAR}'") +endif() diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake index 304c105..7744ee8 100644 --- a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -11,6 +11,9 @@ run_cmake_toolchain(CheckLanguage) run_cmake_toolchain(FlagsInit) run_cmake_toolchain(LangVars) run_cmake_toolchain(LinkFlagsInit) +run_cmake_toolchain(CMP0126-NEW) +run_cmake_toolchain(CMP0126-OLD) +run_cmake_toolchain(CMP0126-WARN) function(run_IncludeDirectories) run_cmake_toolchain(IncludeDirectories) |