[PATCH] D12384: Libc++abi: find libc++ headers w/o find_path

Evgeniy Stepanov via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 15:22:15 PDT 2015


eugenis created this revision.
eugenis added reviewers: EricWF, mclow.lists.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

With http://reviews.llvm.org/D11740, libc++ headers can not be used from the libc++ source directly, because they include an auto-generated header with ABI version numbers.

This change makes libc++abi pick up the headers in the binary dir. Because of cmake inclusion order, those headers are not ready yet when libc++abi CMakeLists is executed, and can not be found with find_path. Hardcode the path to the headers instead.


Repository:
  rL LLVM

http://reviews.llvm.org/D12384

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -119,6 +119,7 @@
 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.")
 set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.")
 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ library.")
+set(LIBCXX_ABI_MAJOR_VERSION 1 CACHE STRING "Major ABI version of libc++.")
 
 # Default to building a shared library so that the default options still test
 # the libc++abi that is being built. There are two problems with testing a
@@ -133,15 +134,21 @@
   message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
 endif()
 
-find_path(
-  LIBCXXABI_LIBCXX_INCLUDES
-  vector
-  PATHS ${LIBCXXABI_LIBCXX_INCLUDES}
-        ${LIBCXXABI_LIBCXX_PATH}/include
-        ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
-        ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
-        ${LLVM_INCLUDE_DIR}/c++/v1
-  )
+if (NOT "${LLVM_MAIN_SRC_DIR}" STREQUAL "")
+  # When building as part of LLVM, libc++ headers will end up under
+  # ${CMAKE_BINARY_DIR}. They are not there yet, so we can not use find_path.
+  set(LIBCXXABI_LIBCXX_INCLUDES
+    ${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_MAJOR_VERSION})
+else()
+  find_path(
+    LIBCXXABI_LIBCXX_INCLUDES
+    vector
+    PATHS ${LIBCXXABI_LIBCXX_INCLUDES}
+          ${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_MAJOR_VERSION}
+          ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
+          ${LLVM_INCLUDE_DIR}/c++/v${LIBCXX_ABI_MAJOR_VERSION}
+    )
+endif()
 
 set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
     "Specify path to libc++ includes." FORCE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12384.33258.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150826/0b150c30/attachment-0001.bin>


More information about the cfe-commits mailing list