From a933c2a939b01a268474d1221e19e41468dde1f7 Mon Sep 17 00:00:00 2001 From: John Brawn Date: Tue, 29 Sep 2015 14:33:58 +0000 Subject: [PATCH] [CMake] Move the setting of LLVM_COMPILER_IS_GCC_COMPATIBLE to a separate file Currently LLVM_COMPILER_IS_GCC_COMPATIBLE is set as a side-effect of determining the stdlib to use in HandleLLVMStdlib, which causes problems when attempting to use AddLLVM from an installed LLVM toolchain, as HandleLLVMStdlib is not used. Move the setting of this variable into DetermineGCCCompatible and include that from both AddLLVM and HandleLLVMStdlib. Differential Revision: http://reviews.llvm.org/D13216 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248798 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/AddLLVM.cmake | 1 + cmake/modules/DetermineGCCCompatible.cmake | 11 +++++++++++ cmake/modules/HandleLLVMStdlib.cmake | 10 ++-------- 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 cmake/modules/DetermineGCCCompatible.cmake diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index dea560182a4..48532288fa6 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -1,5 +1,6 @@ include(LLVMProcessSources) include(LLVM-Config) +include(DetermineGCCCompatible) function(llvm_update_compile_flags name) get_property(sources TARGET ${name} PROPERTY SOURCES) diff --git a/cmake/modules/DetermineGCCCompatible.cmake b/cmake/modules/DetermineGCCCompatible.cmake new file mode 100644 index 00000000000..1bf15fcba72 --- /dev/null +++ b/cmake/modules/DetermineGCCCompatible.cmake @@ -0,0 +1,11 @@ +# Determine if the compiler has GCC-compatible command-line syntax. + +if(NOT DEFINED LLVM_COMPILER_IS_GCC_COMPATIBLE) + if(CMAKE_COMPILER_IS_GNUCXX) + set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) + elseif( MSVC ) + set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF) + elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) + set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) + endif() +endif() diff --git a/cmake/modules/HandleLLVMStdlib.cmake b/cmake/modules/HandleLLVMStdlib.cmake index 66ad078fb66..b07781c3f29 100644 --- a/cmake/modules/HandleLLVMStdlib.cmake +++ b/cmake/modules/HandleLLVMStdlib.cmake @@ -1,17 +1,11 @@ # This CMake module is responsible for setting the standard library to libc++ # if the user has requested it. +include(DetermineGCCCompatible) + if(NOT DEFINED LLVM_STDLIB_HANDLED) set(LLVM_STDLIB_HANDLED ON) - if(CMAKE_COMPILER_IS_GNUCXX) - set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) - elseif( MSVC ) - set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF) - elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) - set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) - endif() - function(append value) foreach(variable ${ARGN}) set(${variable} "${${variable}} ${value}" PARENT_SCOPE) -- 2.34.1