diff options
author | Brad King <brad.king@kitware.com> | 2022-06-10 15:05:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-10 15:05:43 (GMT) |
commit | 865bc4a0682d0681a9cb428eed6c8b18e977e4e8 (patch) | |
tree | e33877fe390be5eb20055badeb8edd4b35a7c6d0 /Modules | |
parent | d63ec8645f5b296bb6b09f47240f26cf44994429 (diff) | |
parent | ec08bc17526a7e22c1a18d5262ca0ca0c391ec6e (diff) | |
download | CMake-865bc4a0682d0681a9cb428eed6c8b18e977e4e8.zip CMake-865bc4a0682d0681a9cb428eed6c8b18e977e4e8.tar.gz CMake-865bc4a0682d0681a9cb428eed6c8b18e977e4e8.tar.bz2 |
Merge topic 'CheckIPOSupported-honor-flags' into release-3.24
ec08bc1752 CheckIPOSupported: Compile check using flags of calling project
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7343
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CheckIPOSupported.cmake | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index 0bc3c92..cca1be9 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -36,6 +36,11 @@ module will return error in this case. See policy :policy:`CMP0069` for details. .. versionadded:: 3.13 Add support for Visual Studio generators. +.. versionadded:: 3.24 + The check uses the caller's :variable:`CMAKE_<LANG>_FLAGS` + and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values. + See policy :policy:`CMP0138`. + Examples ^^^^^^^^ @@ -117,6 +122,16 @@ macro(_ipo_run_language_check language) ) endforeach() + if(ipo_CMP0138 STREQUAL "NEW") + set(CMAKE_TRY_COMPILE_CONFIGURATION Debug) + set(_CMAKE_LANG_FLAGS + "-DCMAKE_${language}_FLAGS:STRING=${CMAKE_${language}_FLAGS}" + "-DCMAKE_${language}_FLAGS_DEBUG:STRING=${CMAKE_${language}_FLAGS_DEBUG}" + ) + else() + set(_CMAKE_LANG_FLAGS "") + endif() + try_compile( _IPO_LANGUAGE_CHECK_RESULT "${bindir}" @@ -125,6 +140,7 @@ macro(_ipo_run_language_check language) CMAKE_FLAGS "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" + ${_CMAKE_LANG_FLAGS} OUTPUT_VARIABLE output ) set(_IPO_LANGUAGE_CHECK_RESULT "${_IPO_LANGUAGE_CHECK_RESULT}") @@ -155,6 +171,11 @@ function(check_ipo_supported) message(FATAL_ERROR "Policy CMP0069 set to OLD") endif() + # Save policy setting for condition in _ipo_run_language_check. + cmake_policy(GET CMP0138 ipo_CMP0138 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) + set(optional) set(one RESULT OUTPUT) set(multiple LANGUAGES) |