mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Diagnostics: Fix passing diagnostic state to try_compile
Do not propagate deprecated diagnostic variables to try_compile. Instead, if any diagnostic is ignored in the calling instance, also ignore it in the try_compile instance.
This commit is contained in:
@@ -84,7 +84,6 @@ std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES =
|
||||
"CMAKE_TRY_COMPILE_OSX_ARCHITECTURES";
|
||||
std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES =
|
||||
"CMAKE_TRY_COMPILE_PLATFORM_VARIABLES";
|
||||
std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED";
|
||||
std::string const kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT =
|
||||
"CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT";
|
||||
std::string const kCMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT =
|
||||
@@ -1136,7 +1135,6 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
||||
vars.insert(kCMAKE_SYSROOT);
|
||||
vars.insert(kCMAKE_SYSROOT_COMPILE);
|
||||
vars.insert(kCMAKE_SYSROOT_LINK);
|
||||
vars.insert(kCMAKE_WARN_DEPRECATED);
|
||||
vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s);
|
||||
vars.emplace("CMAKE_WATCOM_RUNTIME_LIBRARY"_s);
|
||||
vars.emplace("CMAKE_MSVC_DEBUG_INFORMATION_FORMAT"_s);
|
||||
|
||||
@@ -3348,12 +3348,12 @@ int cmMakefile::TryCompile(std::string const& srcdir,
|
||||
// to save time we pass the EnableLanguage info directly
|
||||
cm.GetGlobalGenerator()->EnableLanguagesFromGenerator(
|
||||
this->GetGlobalGenerator(), this);
|
||||
if (this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
|
||||
cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "",
|
||||
cmStateEnums::INTERNAL);
|
||||
} else {
|
||||
cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "",
|
||||
cmStateEnums::INTERNAL);
|
||||
for (unsigned dc = 1; dc < cmDiagnostics::CategoryCount; ++dc) {
|
||||
auto const category = static_cast<cmDiagnosticCategory>(dc);
|
||||
if (this->GetDiagnosticAction(category) == cmDiagnostics::Ignore) {
|
||||
cm.GetCurrentSnapshot().SetDiagnostic(category, cmDiagnostics::Ignore,
|
||||
false);
|
||||
}
|
||||
}
|
||||
if (cm.Configure() != 0) {
|
||||
this->IssueMessage(MessageType::FATAL_ERROR,
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
Executing try_compile \(CMAKE_C_ABI_COMPILED\) in:
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/try_compile/WarnDeprecated-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+
|
||||
]*/Tests/RunCMake/try_compile/CudaArchitectures-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+
|
||||
Call Stack \(most recent call first\):
|
||||
[^
|
||||
]*/Modules/CMakeTestCCompiler\.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)
|
||||
WarnDeprecated\.cmake:[0-9]+ \(enable_language\)
|
||||
CudaArchitectures\.cmake:[0-9]+ \(enable_language\)
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
enable_language(C)
|
||||
|
||||
set(CMAKE_WARN_DEPRECATED SOME_VALUE)
|
||||
set(CMAKE_CUDA_ARCHITECTURES SOME_VALUE)
|
||||
|
||||
try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c
|
||||
@@ -12,7 +12,7 @@ endif()
|
||||
|
||||
# Check that the cache was populated with our custom variable.
|
||||
file(STRINGS ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeCache.txt entries
|
||||
REGEX CMAKE_WARN_DEPRECATED:UNINITIALIZED=${CMAKE_WARN_DEPRECATED}
|
||||
REGEX CMAKE_CUDA_ARCHITECTURES:UNINITIALIZED=${CMAKE_CUDA_ARCHITECTURES}
|
||||
)
|
||||
if(NOT entries)
|
||||
message(FATAL_ERROR "try_compile did not populate cache as expected")
|
||||
@@ -52,7 +52,7 @@ run_cmake(ProjectVars)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --debug-trycompile)
|
||||
run_cmake(PlatformVariables)
|
||||
run_cmake(WarnDeprecated)
|
||||
run_cmake(CudaArchitectures)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND
|
||||
|
||||
Reference in New Issue
Block a user