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)