From: Shoaib Meenai Date: Fri, 8 Dec 2017 19:42:47 +0000 (+0000) Subject: [cmake] Only pass CMAKE_SYSROOT if non-empty X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64c40f56d137544f3c14d1d5b78a41d0dce82a25;p=llvm [cmake] Only pass CMAKE_SYSROOT if non-empty In my build environment (cmake 3.6.1 and gcc 4.8.5 on CentOS 7), having an empty CMAKE_SYSROOT in the cache results in --sysroot="" being passed to all compile commands, and then the compiler errors out because of the empty sysroot. Only set CMAKE_SYSROOT if non-empty to avoid this. Differential Revision: https://reviews.llvm.org/D40934 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320183 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/LLVMExternalProjectUtils.cmake b/cmake/modules/LLVMExternalProjectUtils.cmake index 709c7c2556c..521bd0ffe98 100644 --- a/cmake/modules/LLVMExternalProjectUtils.cmake +++ b/cmake/modules/LLVMExternalProjectUtils.cmake @@ -132,6 +132,10 @@ function(llvm_ExternalProject_Add name source_dir) set(exclude EXCLUDE_FROM_ALL 1) endif() + if(CMAKE_SYSROOT) + set(sysroot_arg -DCMAKE_SYSROOT=${CMAKE_SYSROOT}) + endif() + ExternalProject_Add(${name} DEPENDS ${ARG_DEPENDS} llvm-config ${name}-clobber @@ -143,7 +147,7 @@ function(llvm_ExternalProject_Add name source_dir) CMAKE_ARGS ${${nameCanon}_CMAKE_ARGS} ${compiler_args} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DCMAKE_SYSROOT=${CMAKE_SYSROOT} + ${sysroot_arg} -DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR} -DLLVM_CONFIG_PATH=$ -DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}