diff options
author | Brad King <brad.king@kitware.com> | 2022-10-18 09:12:10 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-10-18 13:38:00 -0400 |
commit | 50e90e282847f1109e5559d49fc12214b3493fff (patch) | |
tree | eb14171de7c42a755f0afab1b7db20b97dbf07fc /Tests/RunCMake/try_compile/RunCMakeTest.cmake | |
parent | 367f10f4cbeb5d782e08a6e29ea5678fa4e71d14 (diff) | |
download | cmake-50e90e282847f1109e5559d49fc12214b3493fff.tar.gz |
try_compile: Honor CMP0128 setting in test project
Some projects pass a raw `-std=` flag to the compiler in the
`try_compile` project. If they do not set CMP0128 to NEW,
we should not append a `-std=` flag where we did not before
the policy was added.
Fixes: #24063
Diffstat (limited to 'Tests/RunCMake/try_compile/RunCMakeTest.cmake')
-rw-r--r-- | Tests/RunCMake/try_compile/RunCMakeTest.cmake | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index dcd37996e5..4301cf7ee3 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -114,6 +114,23 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() +# Lookup CMAKE_CXX_EXTENSIONS_DEFAULT. +# FIXME: Someday we could move this to the top of the file and use it in +# place of some of the values passed by 'Tests/RunCMake/CMakeLists.txt'. +run_cmake(Inspect) +include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") + +# FIXME: Support more compilers and default standard levels. +if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang)$" + AND DEFINED CMAKE_CXX_STANDARD_DEFAULT + AND DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT + ) + run_cmake(CMP0128-WARN) + if(NOT CMAKE_CXX_STANDARD_DEFAULT EQUAL 11) + run_cmake(CMP0128-NEW) + endif() +endif() + if(UNIX) run_cmake(CleanupNoFollowSymlink) endif() |