OSDN Git Service

[cmake] Only pass CMAKE_SYSROOT if non-empty
authorShoaib Meenai <smeenai@fb.com>
Fri, 8 Dec 2017 19:42:47 +0000 (19:42 +0000)
committerShoaib Meenai <smeenai@fb.com>
Fri, 8 Dec 2017 19:42:47 +0000 (19:42 +0000)
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

cmake/modules/LLVMExternalProjectUtils.cmake

index 709c7c2..521bd0f 100644 (file)
@@ -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=$<TARGET_FILE:llvm-config>
                -DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}