[PATCH] D62640: [CMake] Use find_package(LLVM) instead of LLVMConfig

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 20:08:12 PDT 2019


phosek updated this revision to Diff 202108.
Herald added subscribers: libcxx-commits, christof.
Herald added a project: libc++.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62640/new/

https://reviews.llvm.org/D62640

Files:
  libunwind/CMakeLists.txt
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -59,12 +59,13 @@
   cmake_minimum_required(VERSION 3.4.3)
   project(Runtimes C CXX ASM)
 
+  find_package(LLVM)
+
   # Add the root project's CMake modules, and the LLVM build's modules to the
   # CMake module path.
   list(INSERT CMAKE_MODULE_PATH 0
     "${CMAKE_CURRENT_SOURCE_DIR}/../cmake"
     "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
-    "${LLVM_LIBRARY_DIR}/cmake/llvm"
   )
 
   # Some of the runtimes will conditionally use the compiler-rt sanitizers
@@ -79,19 +80,14 @@
     endif()
   endif()
 
-  # LLVMConfig.cmake contains a bunch of CMake variables from the LLVM build.
-  # This file is installed as part of LLVM distributions, so this can be used
-  # either from a build directory or an installed LLVM.
-  include(LLVMConfig)
-
   # Setting these variables will allow the sub-build to put their outputs into
   # the library and bin directories of the top-level build.
+  set(LLVM_BINARY_DIR ${LLVM_BUILD_BINARY_DIR})
+  set(LLVM_LIBRARY_DIR ${LLVM_BUILD_LIBRARY_DIR})
   set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
 
   # This variable makes sure that e.g. llvm-lit is found.
-  set(LLVM_BINARY_DIR ${LLVM_BUILD_BINARY_DIR})
-  set(LLVM_LIBRARY_DIR ${LLVM_BUILD_LIBRARY_DIR})
   set(LLVM_INCLUDE_DIR ${LLVM_BUILD_MAIN_INCLUDE_DIR})
   set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
   set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===================================================================
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -234,6 +234,7 @@
                -DPACKAGE_VERSION=${PACKAGE_VERSION}
                -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
+               -DCMAKE_PREFIX_PATH=${LLVM_BINARY_DIR}
                -DCMAKE_EXPORT_COMPILE_COMMANDS=1
                ${cmake_args}
                ${PASSTHROUGH_VARIABLES}
Index: libunwind/CMakeLists.txt
===================================================================
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -15,7 +15,7 @@
   ${CMAKE_MODULE_PATH}
   )
 
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_BUILD)
   project(libunwind)
 
   # Rely on llvm-config.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62640.202108.patch
Type: text/x-patch
Size: 2611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/070ca5d1/attachment.bin>


More information about the llvm-commits mailing list