mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
Merge topic 'toolchain-CMP0126'
144be54dd3 try_compile: Propagate CMP0126 to the generated test project
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6366
This commit is contained in:
@@ -570,6 +570,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
||||
*cmp0123 == "NEW"_s ? "NEW" : "OLD");
|
||||
}
|
||||
|
||||
/* Set cache/normal variable policy to match outer project.
|
||||
It may affect toolchain files. */
|
||||
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) !=
|
||||
cmPolicies::NEW) {
|
||||
fprintf(fout, "cmake_policy(SET CMP0126 OLD)\n");
|
||||
}
|
||||
|
||||
std::string projectLangs;
|
||||
for (std::string const& li : testLangs) {
|
||||
projectLangs += " " + li;
|
||||
|
||||
1
Tests/RunCMake/ToolchainFile/CMP0126-NEW-stderr.txt
Normal file
1
Tests/RunCMake/ToolchainFile/CMP0126-NEW-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
^try_compile CMP0126='NEW' VAR='1'
|
||||
1
Tests/RunCMake/ToolchainFile/CMP0126-NEW-toolchain.cmake
Normal file
1
Tests/RunCMake/ToolchainFile/CMP0126-NEW-toolchain.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/CMP0126-toolchain.cmake")
|
||||
2
Tests/RunCMake/ToolchainFile/CMP0126-NEW.cmake
Normal file
2
Tests/RunCMake/ToolchainFile/CMP0126-NEW.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
cmake_policy(SET CMP0126 NEW)
|
||||
enable_language(C)
|
||||
1
Tests/RunCMake/ToolchainFile/CMP0126-OLD-stderr.txt
Normal file
1
Tests/RunCMake/ToolchainFile/CMP0126-OLD-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
^try_compile CMP0126='OLD' VAR='2'
|
||||
1
Tests/RunCMake/ToolchainFile/CMP0126-OLD-toolchain.cmake
Normal file
1
Tests/RunCMake/ToolchainFile/CMP0126-OLD-toolchain.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/CMP0126-toolchain.cmake")
|
||||
2
Tests/RunCMake/ToolchainFile/CMP0126-OLD.cmake
Normal file
2
Tests/RunCMake/ToolchainFile/CMP0126-OLD.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
cmake_policy(SET CMP0126 OLD)
|
||||
enable_language(C)
|
||||
1
Tests/RunCMake/ToolchainFile/CMP0126-WARN-stderr.txt
Normal file
1
Tests/RunCMake/ToolchainFile/CMP0126-WARN-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
^try_compile CMP0126='OLD' VAR='2'
|
||||
@@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/CMP0126-toolchain.cmake")
|
||||
2
Tests/RunCMake/ToolchainFile/CMP0126-WARN.cmake
Normal file
2
Tests/RunCMake/ToolchainFile/CMP0126-WARN.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
# leave CMP0126 unset
|
||||
enable_language(C)
|
||||
7
Tests/RunCMake/ToolchainFile/CMP0126-toolchain.cmake
Normal file
7
Tests/RunCMake/ToolchainFile/CMP0126-toolchain.cmake
Normal file
@@ -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()
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user