]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: unset all cxx flags before testing cxx_atomics
authorKefu Chai <tchaikov@gmail.com>
Tue, 19 Jul 2022 04:54:25 +0000 (12:54 +0800)
committerJustin Caratzas <jcaratza@redhat.com>
Fri, 16 Sep 2022 18:54:54 +0000 (14:54 -0400)
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>
cmake/modules/CheckCxxAtomic.cmake

index da2be5206d634e2b5b42bd921b8cf8492e37491a..78c0f988707a0577f79878c1f02febfbbe34b7a3 100644 (file)
@@ -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 <atomic>
 #include <cstdint>
@@ -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()