diff options
author | Craig Scott <craig.scott@crascit.com> | 2022-03-23 03:31:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-03-29 13:42:59 (GMT) |
commit | 05e510bf0bf8d730b03e8b389d088919825b4b5a (patch) | |
tree | 12fc8e73e25bf76f2e6b243ce4469dae64c84370 /Tests/RunCMake/CMP0132 | |
parent | 774a9eb210c09da97135cb733828752e627c96c7 (diff) | |
download | CMake-05e510bf0bf8d730b03e8b389d088919825b4b5a.zip CMake-05e510bf0bf8d730b03e8b389d088919825b4b5a.tar.gz CMake-05e510bf0bf8d730b03e8b389d088919825b4b5a.tar.bz2 |
CMP0132: Don't set compiler environment variables on first run
When running CMake for the first time in a build tree, for some
generators CMake would set compiler environment variables
like CC, CXX, etc. when the corresponding language is enabled.
That behavior was never documented and can result in different
behavior between the first and subsequent runs. Add a policy
to no longer set those environment variables.
Fixes: #21378
Diffstat (limited to 'Tests/RunCMake/CMP0132')
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-Common.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-NEW.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-OLD.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMP0132-WARN.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0132/RunCMakeTest.cmake | 7 |
9 files changed, 34 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0132/CMP0132-Common.cmake b/Tests/RunCMake/CMP0132/CMP0132-Common.cmake new file mode 100644 index 0000000..796f61c --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-Common.cmake @@ -0,0 +1,15 @@ +if(NOT "$ENV{CC}" STREQUAL "") + message(STATUS "Test environment already sets CC, test being SKIPPED") + return() +elseif(CMAKE_GENERATOR MATCHES "Xcode|Visual Studio") + message(STATUS "This generator never sets CC, test being SKIPPED") + return() +endif() + +enable_language(C) + +if("$ENV{CC}" STREQUAL "") + message(STATUS "CC was left unset") +else() + message(STATUS "CC was set to $ENV{CC}") +endif() diff --git a/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt new file mode 100644 index 0000000..8056c2c --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was left unset diff --git a/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake b/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake new file mode 100644 index 0000000..fabb419 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0132 NEW) +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt new file mode 100644 index 0000000..c131428 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was set diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake b/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake new file mode 100644 index 0000000..aae4f2a --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0132 OLD) +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt new file mode 100644 index 0000000..c131428 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was set diff --git a/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake b/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake new file mode 100644 index 0000000..c07e5db --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMakeLists.txt b/Tests/RunCMake/CMP0132/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0132/RunCMakeTest.cmake b/Tests/RunCMake/CMP0132/RunCMakeTest.cmake new file mode 100644 index 0000000..db599ce --- /dev/null +++ b/Tests/RunCMake/CMP0132/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +if(NOT CMAKE_GENERATOR_NO_COMPILER_ENV) + run_cmake(CMP0132-WARN) + run_cmake(CMP0132-OLD) + run_cmake(CMP0132-NEW) +endif() |