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 <tchaikov@gmail.com>
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 <atomic>
#include <cstdint>
endfunction(check_cxx_atomics)
cmake_push_check_state()
+unset(CMAKE_REQUIRED_LIBRARIES)
check_cxx_atomics(HAVE_CXX11_ATOMIC)
cmake_pop_check_state()