1 cmake_minimum_required(VERSION 3.20.0)
3 if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libunwind")
4 message(FATAL_ERROR "llvm-libgcc requires being built in a monorepo layout with libunwind available")
7 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
9 list(APPEND CMAKE_MODULE_PATH
10 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
11 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
12 "${LLVM_COMMON_CMAKE_UTILS}"
13 "${LLVM_COMMON_CMAKE_UTILS}/Modules"
16 project(llvm-libgcc LANGUAGES C CXX ASM)
18 if(NOT LLVM_LIBGCC_EXPLICIT_OPT_IN)
20 "llvm-libgcc is not for the casual LLVM user. It is intended to be used by distro "
21 "managers who want to replace libgcc with compiler-rt and libunwind, but cannot "
22 "fully abandon the libgcc family (e.g. because they are dependent on glibc). Such "
23 "managers must have worked out their compatibility requirements ahead of using "
24 "llvm-libgcc. If you want to build llvm-libgcc, please add -DLLVM_LIBGCC_EXPLICIT_OPT_IN=Yes "
25 "to your CMake invocation and try again.")
28 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib${LLVMLIB_DIR_SUFFIX}")
29 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib${LLVMLIB_DIR_SUFFIX}")
30 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
32 set(COMPILER_RT_BUILD_BUILTINS On)
33 set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS Off)
34 add_subdirectory("../compiler-rt" "compiler-rt")
36 set(LIBUNWIND_ENABLE_STATIC On)
37 set(LIBUNWIND_ENABLE_SHARED Off)
38 set(LIBUNWIND_HAS_COMMENT_LIB_PRAGMA Off)
39 set(LIBUNWIND_USE_COMPILER_RT On)
40 add_subdirectory("../libunwind" "libunwind")