[PATCH] D24005: [compiler-rt cmake] Support overriding llvm-config query results

Michał Górny via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 29 14:44:18 PDT 2016


mgorny created this revision.
mgorny added reviewers: samsonov, Hahnfeld.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: dberris.

Support overriding LLVM_* variables obtained from llvm-config when doing stand-alone builds. The override of LLVM_MAIN_SRC_DIR is necessary to provide LLVM sources when the initial directory used to build LLVM does
no longer exist when compiler-rt is built stand-alone. This is especially the case when building the projects separately in temporary directories with unpredictable names.

The code is based on existing CMakeLists.txt from clang. Alike clang, it extends the override to all queried variables.


https://reviews.llvm.org/D24005

Files:
  cmake/Modules/CompilerRTUtils.cmake

Index: cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- cmake/Modules/CompilerRTUtils.cmake
+++ cmake/Modules/CompilerRTUtils.cmake
@@ -197,10 +197,15 @@
     message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
   endif()
   string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT})
-  list(GET CONFIG_OUTPUT 0 LLVM_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 1 LLVM_TOOLS_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 2 LLVM_LIBRARY_DIR)
-  list(GET CONFIG_OUTPUT 3 LLVM_MAIN_SRC_DIR)
+  list(GET CONFIG_OUTPUT 0 LLVM_OBJ_ROOT)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 MAIN_SRC_DIR)
+
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
   # Make use of LLVM CMake modules.
   file(TO_CMAKE_PATH ${LLVM_BINARY_DIR} LLVM_BINARY_DIR_CMAKE_STYLE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24005.69616.patch
Type: text/x-patch
Size: 1158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160829/e6af538b/attachment-0001.bin>


More information about the cfe-commits mailing list