From: Kefu Chai Date: Tue, 19 Jul 2022 04:54:25 +0000 (+0800) Subject: cmake: unset all cxx flags before testing cxx_atomics X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e62b1bbc4b540008dc6404761439124b9cedc6ef;p=ceph.git cmake: unset all cxx flags before testing cxx_atomics so we are immune to the flags set by the flags set by user. please note, neither CFLAGS nor CXXFLAGS is populated to the `check_cxx_source_compiles()` function. so this change is not related to LTO optimization which is implemented using `_lto_cflags`, which is added to CFLAGS and CXXFLAGS, as part of `__global_compiler_flags`. See-also: https://tracker.ceph.com/issues/54514 See-also: https://tracker.ceph.com/issues/56492 Signed-off-by: Kefu Chai --- diff --git a/cmake/modules/CheckCxxAtomic.cmake b/cmake/modules/CheckCxxAtomic.cmake index da2be5206d634..78c0f988707a0 100644 --- a/cmake/modules/CheckCxxAtomic.cmake +++ b/cmake/modules/CheckCxxAtomic.cmake @@ -6,7 +6,10 @@ include(CMakePushCheckState) function(check_cxx_atomics var) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11") + set(CMAKE_REQUIRED_FLAGS "-std=c++11") + unset(CMAKE_CXX_FLAGS) + unset(CMAKE_REQUIRED_DEFINITIONS) + unset(CMAKE_REQUIRED_LINK_OPTIONS) check_cxx_source_compiles(" #include #include @@ -38,6 +41,7 @@ int main() { endfunction(check_cxx_atomics) cmake_push_check_state() +unset(CMAKE_REQUIRED_LIBRARIES) check_cxx_atomics(HAVE_CXX11_ATOMIC) cmake_pop_check_state()