From 2d99b052457b78753313704338a9edbb1561ab36 Mon Sep 17 00:00:00 2001 From: wangzehong Date: Thu, 16 Feb 2023 16:48:37 +0800 Subject: [PATCH] modify to standalone build --- CMakeLists.txt | 34 +++++++++++++++++++++++++++++----- docs/CMakeLists.txt | 1 + 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/libunwind-12.0.1.src/CMakeLists.txt b/libunwind-12.0.1.src/CMakeLists.txt index 570b8db..14e1b11 100644 --- a/libunwind-12.0.1.src/CMakeLists.txt +++ b/libunwind-12.0.1.src/CMakeLists.txt @@ -1,6 +1,3 @@ -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 @@ -37,9 +34,36 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_B # the configurator should write the script into. set(LIBUNWIND_STANDALONE_BUILD 1) set(LLVM_LIT_OUTPUT_DIR "${LIBUNWIND_BINARY_DIR}/bin") + find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary") + if(NOT LLVM_CONFIG_PATH) + message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH") + endif() + + execute_process(COMMAND "${LLVM_CONFIG_PATH}" + "--obj-root" + "--includedir" + "--cmakedir" + "--src-root" + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(HAD_ERROR) + message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") + endif() + + string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" LLVM_CONFIG_OUTPUT "${LLVM_CONFIG_OUTPUT}") + + list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT) + list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR) + list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_PATH) + list(GET LLVM_CONFIG_OUTPUT 3 MAIN_SRC_DIR) + + if(NOT EXISTS "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") + message(FATAL_ERROR "LLVMConfig.cmake not found") + endif() + include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") - # Find the LLVM sources and simulate LLVM CMake options. - include(HandleOutOfTreeLLVM) + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") else() set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py") endif() diff --git a/libunwind-12.0.1.src/docs/CMakeLists.txt b/libunwind-12.0.1.src/docs/CMakeLists.txt index c226f2f..17fb075 100644 --- a/libunwind-12.0.1.src/docs/CMakeLists.txt +++ b/libunwind-12.0.1.src/docs/CMakeLists.txt @@ -2,6 +2,7 @@ include(FindSphinx) if (SPHINX_FOUND) include(AddSphinxTarget) + include(AddLLVM) if (${SPHINX_OUTPUT_HTML}) add_sphinx_target(html libunwind) endif() endif() -- 2.33.1.windows.1