summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/try_compile
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-05-16 14:04:48 (GMT)
committerBrad King <brad.king@kitware.com>2022-05-16 14:39:42 (GMT)
commit4843a376767c2c4b46e29ed85ac823443317ca40 (patch)
tree0a957181b6b5e352e5793d2ff845b365fed50e59 /Tests/RunCMake/try_compile
parent364fde65ee93588cb519ece09b161c0e8e826c3c (diff)
downloadCMake-4843a376767c2c4b46e29ed85ac823443317ca40.zip
CMake-4843a376767c2c4b46e29ed85ac823443317ca40.tar.gz
CMake-4843a376767c2c4b46e29ed85ac823443317ca40.tar.bz2
try_compile: Propagate platform variables in project-mode too
Add policy CMP0137 to propagate both our builtin variables and those listed by `CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` to `try_compile` whole-project builds. Inspired-by: Alexander Neumann <Alexander.Neumann@hamburg.de> Fixes: #23219
Diffstat (limited to 'Tests/RunCMake/try_compile')
-rw-r--r--Tests/RunCMake/try_compile/CMP0137-Common.cmake8
-rw-r--r--Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt2
-rw-r--r--Tests/RunCMake/try_compile/CMP0137-NEW.cmake2
-rw-r--r--Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt2
-rw-r--r--Tests/RunCMake/try_compile/CMP0137-WARN.cmake2
-rw-r--r--Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake2
7 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/try_compile/CMP0137-Common.cmake b/Tests/RunCMake/try_compile/CMP0137-Common.cmake
new file mode 100644
index 0000000..867475d
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0137-Common.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_ENABLE_EXPORTS 1)
+set(FOO 2)
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES FOO)
+try_compile(RESULT_VAR
+ ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build
+ ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137
+ TestCMP0137)
+include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build/info.cmake OPTIONAL)
diff --git a/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt b/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt
new file mode 100644
index 0000000..0a6bb38
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt
@@ -0,0 +1,2 @@
+-- CMAKE_ENABLE_EXPORTS='1'
+-- FOO='2'
diff --git a/Tests/RunCMake/try_compile/CMP0137-NEW.cmake b/Tests/RunCMake/try_compile/CMP0137-NEW.cmake
new file mode 100644
index 0000000..f7caa50
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0137-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0137 NEW)
+include(CMP0137-Common.cmake)
diff --git a/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt b/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt
new file mode 100644
index 0000000..fda1e41
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt
@@ -0,0 +1,2 @@
+-- CMAKE_ENABLE_EXPORTS=''
+-- FOO=''
diff --git a/Tests/RunCMake/try_compile/CMP0137-WARN.cmake b/Tests/RunCMake/try_compile/CMP0137-WARN.cmake
new file mode 100644
index 0000000..61b5641
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0137-WARN.cmake
@@ -0,0 +1,2 @@
+# policy CMP0137 not set
+include(CMP0137-Common.cmake)
diff --git a/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt b/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt
new file mode 100644
index 0000000..a3b9fda
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.23)
+project(TestCMP0137 NONE)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "
+message(STATUS \"CMAKE_ENABLE_EXPORTS='${CMAKE_ENABLE_EXPORTS}'\")
+message(STATUS \"FOO='${FOO}'\")
+")
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index dcd3799..eca7bf4 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -72,6 +72,8 @@ endif()
run_cmake(CMP0056)
run_cmake(CMP0066)
run_cmake(CMP0067)
+run_cmake(CMP0137-WARN)
+run_cmake(CMP0137-NEW)
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
# Use a single build tree for a few tests without cleaning.