${CMAKE_MODULE_PATH}
)
+set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD)
project(libcxx CXX C)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
+ # In a standalone build, we don't have llvm to automatically generate the
+ # llvm-lit script for us. So we need to provide an explicit directory that
+ # the configurator should write the script into.
+ set(LIBCXX_STANDALONE_BUILD 1)
+ set(LLVM_LIT_OUTPUT_DIR "${LIBCXX_BINARY_DIR}/bin")
+
# Find the LLVM sources and simulate LLVM CMake options.
include(HandleOutOfTreeLLVM)
endif()
# Configure System
#===============================================================================
-set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
-
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR})
endif()
message(STATUS "Configuring for standalone build.")
-set(LIBCXX_STANDALONE_BUILD 1)
# Add LLVM Functions --------------------------------------------------------
if (WIN32)
set(LLVM_ENABLE_SPHINX OFF)
endif()
-# In a standalone build, we don't have llvm to automatically generate the
-# llvm-lit script for us. So we need to provide an explicit directory that
-# the configurator should write the script into.
-set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
-
if (LLVM_INCLUDE_TESTS)
# Required LIT Configuration ------------------------------------------------
# Define the default arguments to use with 'lit', and an option for the user
${CMAKE_MODULE_PATH}
)
+set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
+ "Specify path to libc++ source.")
+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
project(libcxxabi CXX C)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
+ # Add the CMake module path of libcxx so we can reuse HandleOutOfTreeLLVM.cmake
+ set(LIBCXXABI_LIBCXX_CMAKE_PATH "${LIBCXXABI_LIBCXX_PATH}/cmake/Modules")
+ list(APPEND CMAKE_MODULE_PATH "${LIBCXXABI_LIBCXX_CMAKE_PATH}")
+
+ # In a standalone build, we don't have llvm to automatically generate the
+ # llvm-lit script for us. So we need to provide an explicit directory that
+ # the configurator should write the script into.
+ set(LIBCXXABI_STANDALONE_BUILD 1)
+ set(LLVM_LIT_OUTPUT_DIR "${LIBCXXABI_BINARY_DIR}/bin")
+
# Find the LLVM sources and simulate LLVM CMake options.
include(HandleOutOfTreeLLVM)
endif()
message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
endif()
-set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
- "Specify path to libc++ source.")
set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_PATH}/include" CACHE PATH
"Specify path to libc++ includes.")
message(STATUS "Libc++abi will be using libc++ includes from ${LIBCXXABI_LIBCXX_INCLUDES}")
${CMAKE_MODULE_PATH}
)
-set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
add_subdirectory(src)
if (LIBCXXABI_INCLUDE_TESTS)
- if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED)
- # We can't reasonably test the system C++ library with a static
- # libc++abi. We either need to be able to replace libc++abi at
- # run time (with a shared libc++abi), or we need to be able to
- # replace the C++ runtime (with a non- standalone build).
- message(WARNING "The libc++abi tests aren't valid when libc++abi "
- "is built standalone (i.e. outside of "
- "llvm/projects/libcxxabi ) and is built without "
- "a shared library. Either build a shared "
- "library, build libc++abi at the same time as "
- "you build libc++, or do without testing. No "
- "check target will be available!")
- else()
- add_subdirectory(test)
- add_subdirectory(fuzz)
- endif()
+ add_subdirectory(test)
+ add_subdirectory(fuzz)
endif()
+++ /dev/null
-macro(find_llvm_parts)
-# Rely on llvm-config.
- set(CONFIG_OUTPUT)
- if(NOT LLVM_CONFIG_PATH)
- find_program(LLVM_CONFIG_PATH "llvm-config")
- endif()
- if(DEFINED LLVM_PATH)
- set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
- set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
- set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
- set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
- if (NOT IS_DIRECTORY "${LLVM_PATH}")
- message(FATAL_ERROR "The provided LLVM_PATH (${LLVM_PATH}) is not a valid directory")
- endif()
- elseif(LLVM_CONFIG_PATH)
- message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}")
- set(LIBCXXABI_USING_INSTALLED_LLVM 1)
- set(CONFIG_COMMAND ${LLVM_CONFIG_PATH}
- "--includedir"
- "--prefix"
- "--src-root")
- execute_process(
- COMMAND ${CONFIG_COMMAND}
- RESULT_VARIABLE HAD_ERROR
- OUTPUT_VARIABLE CONFIG_OUTPUT
- )
- if(NOT HAD_ERROR)
- string(REGEX REPLACE
- "[ \t]*[\r\n]+[ \t]*" ";"
- CONFIG_OUTPUT ${CONFIG_OUTPUT})
- else()
- string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
- message(STATUS "${CONFIG_COMMAND_STR}")
- message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
- endif()
-
- list(GET CONFIG_OUTPUT 0 INCLUDE_DIR)
- list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
- list(GET CONFIG_OUTPUT 2 MAIN_SRC_DIR)
-
- set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
- set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
- set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-
- # --cmakedir is supported since llvm r291218 (4.0 release)
- execute_process(
- COMMAND ${LLVM_CONFIG_PATH} --cmakedir
- RESULT_VARIABLE HAD_ERROR
- OUTPUT_VARIABLE CONFIG_OUTPUT
- ERROR_QUIET)
- if(NOT HAD_ERROR)
- string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH_FROM_LLVM_CONFIG)
- file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH_FROM_LLVM_CONFIG}" LLVM_CMAKE_PATH)
- else()
- file(TO_CMAKE_PATH "${LLVM_BINARY_DIR}" LLVM_BINARY_DIR_CMAKE_STYLE)
- set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR_CMAKE_STYLE}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
- endif()
- else()
- set(LLVM_FOUND OFF)
- message(WARNING "UNSUPPORTED LIBCXXABI CONFIGURATION DETECTED: "
- "llvm-config not found and LLVM_PATH not defined.\n"
- "Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config "
- "or -DLLVM_PATH=path/to/llvm-source-root.")
- return()
- endif()
-
- if (EXISTS "${LLVM_CMAKE_PATH}")
- list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
- elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
- list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
- else()
- set(LLVM_FOUND OFF)
- message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found")
- return()
- endif()
-
- set(LLVM_FOUND ON)
-endmacro(find_llvm_parts)
-
-macro(configure_out_of_tree_llvm)
- message(STATUS "Configuring for standalone build.")
- set(LIBCXXABI_STANDALONE_BUILD 1)
-
- find_llvm_parts()
-
- # Add LLVM Functions --------------------------------------------------------
- if (LLVM_FOUND AND LIBCXXABI_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 --------------------------------------------------------------
- if (NOT DEFINED LLVM_INCLUDE_TESTS)
- set(LLVM_INCLUDE_TESTS ${LLVM_FOUND})
- endif()
- if (NOT DEFINED LLVM_INCLUDE_DOCS)
- set(LLVM_INCLUDE_DOCS ${LLVM_FOUND})
- endif()
- if (NOT DEFINED LLVM_ENABLE_SPHINX)
- set(LLVM_ENABLE_SPHINX OFF)
- endif()
-
- # In a standalone build, we don't have llvm to automatically generate the
- # llvm-lit script for us. So we need to provide an explicit directory that
- # the configurator should write the script into.
- set(LLVM_LIT_OUTPUT_DIR "${libcxxabi_BINARY_DIR}/bin")
-
- if (LLVM_INCLUDE_TESTS)
- # Required LIT Configuration ------------------------------------------------
- # Define the default arguments to use with 'lit', and an option for the user
- # to override.
- set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
- set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
- if (MSVC OR XCODE)
- set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
- endif()
- set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
- endif()
-
- # Required doc configuration
- if (LLVM_ENABLE_SPHINX)
- find_package(Sphinx REQUIRED)
- endif()
-
- if (LLVM_ON_UNIX AND NOT APPLE)
- set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
- else()
- set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
- endif()
-endmacro(configure_out_of_tree_llvm)
-
-configure_out_of_tree_llvm()
+if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxx")
+ message(FATAL_ERROR "libunwind requires being built in a monorepo layout with libcxx available")
+endif()
+
#===============================================================================
# Setup Project
#===============================================================================
${CMAKE_MODULE_PATH}
)
+set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
+ "Specify path to libc++ source.")
+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_BUILD)
project(libunwind LANGUAGES C CXX ASM)
- # Rely on llvm-config.
- set(CONFIG_OUTPUT)
- if(NOT LLVM_CONFIG_PATH)
- find_program(LLVM_CONFIG_PATH "llvm-config")
- endif()
- if (DEFINED LLVM_PATH)
- set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
- set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
- set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
- set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
- elseif(LLVM_CONFIG_PATH)
- message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}")
- set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} "--includedir" "--prefix" "--src-root")
- execute_process(COMMAND ${CONFIG_COMMAND}
- RESULT_VARIABLE HAD_ERROR
- OUTPUT_VARIABLE CONFIG_OUTPUT)
- if (NOT HAD_ERROR)
- string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";"
- CONFIG_OUTPUT ${CONFIG_OUTPUT})
- else()
- string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
- message(STATUS "${CONFIG_COMMAND_STR}")
- message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
- endif()
-
- list(GET CONFIG_OUTPUT 0 INCLUDE_DIR)
- list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
- list(GET CONFIG_OUTPUT 2 MAIN_SRC_DIR)
-
- set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
- set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
- set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
- set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
-
- # --cmakedir is supported since llvm r291218 (4.0 release)
- execute_process(
- COMMAND ${LLVM_CONFIG_PATH} --cmakedir
- RESULT_VARIABLE HAD_ERROR
- OUTPUT_VARIABLE CONFIG_OUTPUT
- ERROR_QUIET)
- if(NOT HAD_ERROR)
- string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH_FROM_LLVM_CONFIG)
- file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH_FROM_LLVM_CONFIG}" LLVM_CMAKE_PATH)
- else()
- file(TO_CMAKE_PATH "${LLVM_BINARY_DIR}" LLVM_BINARY_DIR_CMAKE_STYLE)
- set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR_CMAKE_STYLE}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
- endif()
- else()
- message(WARNING "UNSUPPORTED LIBUNWIND CONFIGURATION DETECTED: "
- "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
- "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
- "or -DLLVM_PATH=path/to/llvm-source-root.")
- endif()
-
- if (EXISTS ${LLVM_CMAKE_PATH})
- list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
- include("${LLVM_CMAKE_PATH}/AddLLVM.cmake")
- include("${LLVM_CMAKE_PATH}/HandleLLVMOptions.cmake")
- else()
- message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
- endif()
-
set(PACKAGE_NAME libunwind)
set(PACKAGE_VERSION 12.0.0git)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
- if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
- set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
- else()
- # Seek installed Lit.
- find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
- DOC "Path to lit.py")
- endif()
+ # Add the CMake module path of libcxx so we can reuse HandleOutOfTreeLLVM.cmake
+ set(LIBUNWIND_LIBCXX_CMAKE_PATH "${LIBUNWIND_LIBCXX_PATH}/cmake/Modules")
+ list(APPEND CMAKE_MODULE_PATH "${LIBUNWIND_LIBCXX_CMAKE_PATH}")
- if (LLVM_LIT)
- # Define the default arguments to use with 'lit', and an option for the user
- # to override.
- set(LIT_ARGS_DEFAULT "-sv")
- if (MSVC OR XCODE)
- set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
- endif()
- set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
-
- # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
- if (WIN32 AND NOT CYGWIN)
- set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
- endif()
- else()
- set(LLVM_INCLUDE_TESTS OFF)
- endif()
+ # In a standalone build, we don't have llvm to automatically generate the
+ # llvm-lit script for us. So we need to provide an explicit directory that
+ # the configurator should write the script into.
+ set(LIBUNWIND_STANDALONE_BUILD 1)
+ set(LLVM_LIT_OUTPUT_DIR "${LIBUNWIND_BINARY_DIR}/bin")
- set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+ # Find the LLVM sources and simulate LLVM CMake options.
+ include(HandleOutOfTreeLLVM)
else()
set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
endif()
"Additional compiler flags for test programs.")
set(LIBUNWIND_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING
"The Lit testing configuration to use when running the tests.")
+set(LIBUNWIND_TEST_PARAMS "" CACHE STRING
+ "A list of parameters to run the Lit test suite with.")
if (NOT LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_STATIC)
message(FATAL_ERROR "libunwind must be built as either a shared or static library.")
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
${CMAKE_MODULE_PATH})
-set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY)
set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
"TargetInfo to use when setting up test environment.")
-set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../../libcxx")
set(LIBUNWIND_EXECUTOR "${Python3_EXECUTABLE} ${LIBUNWIND_LIBCXX_PATH}/utils/run.py" CACHE STRING
"Executor to use when running tests.")
add_lit_testsuite(check-unwind "Running libunwind tests"
${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS unwind ${LIBUNWIND_TEST_DEPS})
+ DEPENDS unwind ${LIBUNWIND_TEST_DEPS}
+ PARAMS "${LIBUNWIND_TEST_PARAMS}")