diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 537ae80acc0b..2c708968dcea 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -19,16 +19,17 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) -# Find the LLVM sources and simulate LLVM CMake options. -include(HandleOutOfTreeLLVM) -if (LIBCXX_STANDALONE_BUILD) +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(libcxx CXX C) set(PACKAGE_NAME libcxx) set(PACKAGE_VERSION 4.0.0svn) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") + + # Find the LLVM sources and simulate LLVM CMake options. + include(HandleOutOfTreeLLVM) endif() if (LIBCXX_STANDALONE_BUILD AND NOT LLVM_FOUND) @@ -59,7 +60,6 @@ option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY}) option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) - # Benchmark options ----------------------------------------------------------- option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON) set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING @@ -535,11 +535,13 @@ include_directories(include) add_subdirectory(include) add_subdirectory(lib) + if (LIBCXX_INCLUDE_BENCHMARKS) add_subdirectory(benchmarks) endif() if (LIBCXX_INCLUDE_TESTS) add_subdirectory(test) + add_subdirectory(lib/abi) endif() if (LIBCXX_INCLUDE_DOCS) add_subdirectory(docs) diff --git a/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake b/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake index 05b0244c3b54..599d8a1d4b20 100644 --- a/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ b/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -11,6 +11,7 @@ macro(find_llvm_parts) set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules") elseif(LLVM_CONFIG_PATH) message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}") + set(LIBCXX_USING_INSTALLED_LLVM 1) set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} "--includedir" "--prefix" @@ -56,21 +57,28 @@ macro(find_llvm_parts) set(LLVM_FOUND ON) endmacro(find_llvm_parts) -# If this is a standalone build not running as an external project of LLVM -# we need to later make some decisions differently. -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # The intent is that this doesn't necessarily mean the LLVM is installed (it - # could be a build directory), but it means we need to treat the LLVM - # directory as read-only. - set(LIBCXX_USING_INSTALLED_LLVM 1) -endif() - -if (LIBCXX_USING_INSTALLED_LLVM OR LIBCXX_STANDALONE_BUILD) - set(LIBCXX_STANDALONE_BUILD 1) +macro(configure_out_of_tree_llvm) message(STATUS "Configuring for standalone build.") + set(LIBCXX_STANDALONE_BUILD 1) find_llvm_parts() + # Add LLVM Functions -------------------------------------------------------- + if (LLVM_FOUND AND LIBCXX_USING_INSTALLED_LLVM) + include(LLVMConfig) # For TARGET_TRIPLE + else() + if (WIN32) + set(LLVM_ON_UNIX 0) + set(LLVM_ON_WIN32 1) + else() + set(LLVM_ON_UNIX 1) + set(LLVM_ON_WIN32 0) + endif() + endif() + if (LLVM_FOUND) + include(AddLLVM OPTIONAL) + endif() + # LLVM Options -------------------------------------------------------------- include(FindPythonInterp) if( NOT PYTHONINTERP_FOUND ) @@ -103,30 +111,11 @@ if (LIBCXX_USING_INSTALLED_LLVM OR LIBCXX_STANDALONE_BUILD) find_package(Sphinx REQUIRED) endif() - # FIXME - This is cribbed from HandleLLVMOptions.cmake. - if(WIN32) + if (LLVM_ON_UNIX AND NOT APPLE) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) + else() set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) - if(CYGWIN) - set(LLVM_ON_WIN32 0) - set(LLVM_ON_UNIX 1) - else(CYGWIN) - set(LLVM_ON_WIN32 1) - set(LLVM_ON_UNIX 0) - endif(CYGWIN) - else(WIN32) - if(UNIX) - set(LLVM_ON_WIN32 0) - set(LLVM_ON_UNIX 1) - if(APPLE) - set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) - else(APPLE) - set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) - endif(APPLE) - else(UNIX) - MESSAGE(SEND_ERROR "Unable to determine platform") - endif(UNIX) - endif(WIN32) + endif() +endmacro(configure_out_of_tree_llvm) - # Add LLVM Functions -------------------------------------------------------- - include(AddLLVM OPTIONAL) -endif() +configure_out_of_tree_llvm() diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index deed1a11052c..5969c6fa8ba5 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -10,14 +10,18 @@ set(LIBCXX_HEADER_PATTERN ${LIBCXX_SUPPORT_HEADER_PATTERN} ) -if(NOT LIBCXX_USING_INSTALLED_LLVM) - file(COPY . - DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1" - FILES_MATCHING - ${LIBCXX_HEADER_PATTERN} - ) +if (LIBCXX_STANDALONE_BUILD) + set(LIBCXX_BUILD_ROOT "${LIBCXX_BINARY_DIR}") +else() + set(LIBCXX_BUILD_ROOT "${LLVM_BINARY_DIR}") endif() +file(COPY . + DESTINATION "${LIBCXX_BUILD_ROOT}/include/c++/v1" + FILES_MATCHING + ${LIBCXX_HEADER_PATTERN} +) + if (LIBCXX_INSTALL_HEADERS) install(DIRECTORY . DESTINATION include/c++/v1 diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt new file mode 100644 index 000000000000..e67dcbe0fd59 --- /dev/null +++ b/libcxx/lib/abi/CMakeLists.txt @@ -0,0 +1,26 @@ + +# Detect if we are building in the same configuration used to generate +# the abilist files. +if (DEFINED TARGET_TRIPLE + AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist" + AND TARGET cxx_shared + AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" + AND NOT LIBCXX_ABI_UNSTABLE + AND LIBCXX_ABI_VERSION EQUAL "1") + set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE "") +else() + if (NOT DEFINED LIBCXX_HAS_ABILIST_CONFIGURATION) + message(STATUS "libc++ configuration differs from the abilist configuration. check-cxx-abilist target is not supported") + endif() + set(LIBCXX_HAS_ABILIST_CONFIGURATION 0 CACHE "") +endif() + + +if (LIBCXX_HAS_ABILIST_CONFIGURATION) + set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist") + set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_check/sym_diff.py") + add_custom_target(check-cxx-abilist + ${SYMDIFF_EXE} ${ABILIST_FILE} $ + DEPENDS cxx_shared + COMMENT "Testing ABI compatibility...") +endif() diff --git a/libcxx/lib/abi/x86_64-apple-darwin16.0.abilist b/libcxx/lib/abi/x86_64-apple-darwin16.0.0.abilist similarity index 100% rename from libcxx/lib/abi/x86_64-apple-darwin16.0.abilist rename to libcxx/lib/abi/x86_64-apple-darwin16.0.0.abilist diff --git a/libcxx/lib/abi/x86_64-linux-gnu.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.abilist similarity index 100% rename from libcxx/lib/abi/x86_64-linux-gnu.abilist rename to libcxx/lib/abi/x86_64-unknown-linux-gnu.abilist