[llvm] r321434 - [cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones.

Don Hinton via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 24 17:23:09 PST 2017


Author: dhinton
Date: Sun Dec 24 17:23:09 2017
New Revision: 321434

URL: http://llvm.org/viewvc/llvm-project?rev=321434&view=rev
Log:
[cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones.

Summary:
Always respect existing CMAKE_REQUIRED_FLAGS when adding
additional ones.  This is important when cross compiling where
--sysroot and -target were already added.

In particular, this is needed when cross compiling from Darwin to
Linux, since --sysroot is required to find headers and libraries.

Cmake has a similar bug in check_include_file[_cxx] where
CMAKE_REQUIRED_LIBRARIES isn't passed, which causes
try_compile to fail.
(please see https://gitlab.kitware.com/cmake/cmake/merge_requests/1620)

Reviewers: compnerd, silvas, beanz, brad.king

Reviewed By: compnerd

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D41568

Modified:
    llvm/trunk/cmake/config-ix.cmake
    llvm/trunk/cmake/modules/CheckAtomic.cmake
    llvm/trunk/cmake/modules/CheckCompilerVersion.cmake

Modified: llvm/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=321434&r1=321433&r2=321434&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Sun Dec 24 17:23:09 2017
@@ -17,7 +17,7 @@ include(HandleLLVMStdlib)
 
 if( UNIX AND NOT (BEOS OR HAIKU) )
   # Used by check_symbol_exists:
-  set(CMAKE_REQUIRED_LIBRARIES m)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
 endif()
 # x86_64 FreeBSD 9.2 requires libcxxrt to be specified explicitly.
 if( CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND

Modified: llvm/trunk/cmake/modules/CheckAtomic.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CheckAtomic.cmake?rev=321434&r1=321433&r2=321434&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/CheckAtomic.cmake (original)
+++ llvm/trunk/cmake/modules/CheckAtomic.cmake Sun Dec 24 17:23:09 2017
@@ -8,7 +8,7 @@ INCLUDE(CheckLibraryExists)
 
 function(check_working_cxx_atomics varname)
   set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
-  set(CMAKE_REQUIRED_FLAGS "-std=c++11")
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
   CHECK_CXX_SOURCE_COMPILES("
 #include <atomic>
 std::atomic<int> x;

Modified: llvm/trunk/cmake/modules/CheckCompilerVersion.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CheckCompilerVersion.cmake?rev=321434&r1=321433&r2=321434&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/CheckCompilerVersion.cmake (original)
+++ llvm/trunk/cmake/modules/CheckCompilerVersion.cmake Sun Dec 24 17:23:09 2017
@@ -28,7 +28,7 @@ if(NOT DEFINED LLVM_COMPILER_CHECKED)
         # bug in libstdc++4.6 that is fixed in libstdc++4.7.
         set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
         set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
-        set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
+        set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
         check_cxx_source_compiles("
 #include <atomic>
 std::atomic<float> x(0.0f);




More information about the llvm-commits mailing list