2020-08-24 17:01:05 +08:00
|
|
|
if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxx")
|
|
|
|
message(FATAL_ERROR "libunwind requires being built in a monorepo layout with libcxx available")
|
|
|
|
endif()
|
|
|
|
|
2015-04-25 09:46:35 +08:00
|
|
|
#===============================================================================
|
2015-08-07 07:31:37 +08:00
|
|
|
# Setup Project
|
2015-04-25 09:46:35 +08:00
|
|
|
#===============================================================================
|
|
|
|
|
2020-04-22 23:15:05 +08:00
|
|
|
cmake_minimum_required(VERSION 3.13.4)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
|
|
|
if (POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
|
|
|
endif()
|
|
|
|
|
2017-04-12 10:28:07 +08:00
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
)
|
|
|
|
|
2020-08-24 17:01:05 +08:00
|
|
|
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.")
|
|
|
|
|
2019-05-30 15:34:39 +08:00
|
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_BUILD)
|
2020-01-27 04:11:28 +08:00
|
|
|
project(libunwind LANGUAGES C CXX ASM)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
|
|
|
set(PACKAGE_NAME libunwind)
|
2020-07-15 17:40:53 +08:00
|
|
|
set(PACKAGE_VERSION 12.0.0git)
|
2015-04-25 09:46:35 +08:00
|
|
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
2015-08-05 12:01:47 +08:00
|
|
|
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2020-08-24 17:01:05 +08:00
|
|
|
# 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}")
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2020-08-24 17:01:05 +08:00
|
|
|
# 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")
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2020-08-24 17:01:05 +08:00
|
|
|
# Find the LLVM sources and simulate LLVM CMake options.
|
|
|
|
include(HandleOutOfTreeLLVM)
|
2015-04-25 09:46:35 +08:00
|
|
|
else()
|
|
|
|
set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup CMake Options
|
|
|
|
#===============================================================================
|
2018-07-25 07:42:51 +08:00
|
|
|
include(CMakeDependentOption)
|
2017-04-12 10:28:07 +08:00
|
|
|
include(HandleCompilerRT)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
|
|
|
# Define options.
|
2016-06-02 09:02:10 +08:00
|
|
|
option(LIBUNWIND_BUILD_32_BITS "Build 32 bit libunwind" ${LLVM_BUILD_32_BITS})
|
2015-04-25 09:46:35 +08:00
|
|
|
option(LIBUNWIND_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
|
|
|
|
option(LIBUNWIND_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
|
|
|
|
option(LIBUNWIND_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
|
|
|
option(LIBUNWIND_ENABLE_SHARED "Build libunwind as a shared library." ON)
|
2016-08-09 06:55:48 +08:00
|
|
|
option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
|
2016-05-27 16:29:27 +08:00
|
|
|
option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF)
|
2016-07-07 18:55:39 +08:00
|
|
|
option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX registers." OFF)
|
2016-09-28 18:57:15 +08:00
|
|
|
option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
|
2019-05-14 02:45:03 +08:00
|
|
|
option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to refer to pthread functions." OFF)
|
2017-04-12 10:28:07 +08:00
|
|
|
option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
|
2017-03-28 23:21:43 +08:00
|
|
|
option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS})
|
2020-07-29 18:39:41 +08:00
|
|
|
option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF)
|
2020-08-19 03:05:07 +08:00
|
|
|
option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. Requires locking dl_iterate_phdr." OFF)
|
2020-11-11 17:58:41 +08:00
|
|
|
option(LIBUNWIND_REMEMBER_HEAP_ALLOC "Use heap instead of the stack for .cfi_remember_state." OFF)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2017-08-08 08:37:59 +08:00
|
|
|
set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
|
|
|
"Define suffix of library directory name (32/64)")
|
2017-11-18 07:29:46 +08:00
|
|
|
option(LIBUNWIND_INSTALL_LIBRARY "Install the libunwind library." ON)
|
2018-07-25 07:27:51 +08:00
|
|
|
cmake_dependent_option(LIBUNWIND_INSTALL_STATIC_LIBRARY
|
|
|
|
"Install the static libunwind library." ON
|
|
|
|
"LIBUNWIND_ENABLE_STATIC;LIBUNWIND_INSTALL_LIBRARY" OFF)
|
|
|
|
cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY
|
|
|
|
"Install the shared libunwind library." ON
|
|
|
|
"LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF)
|
2016-06-02 09:02:10 +08:00
|
|
|
set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
|
|
|
|
set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
|
|
|
|
set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
|
2018-02-28 02:40:04 +08:00
|
|
|
set(LIBUNWIND_TEST_LINKER_FLAGS "" CACHE STRING
|
|
|
|
"Additional linker flags for test programs.")
|
|
|
|
set(LIBUNWIND_TEST_COMPILER_FLAGS "" CACHE STRING
|
|
|
|
"Additional compiler flags for test programs.")
|
2020-06-26 00:02:43 +08:00
|
|
|
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.")
|
2020-08-24 17:01:05 +08:00
|
|
|
set(LIBUNWIND_TEST_PARAMS "" CACHE STRING
|
|
|
|
"A list of parameters to run the Lit test suite with.")
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2016-08-09 06:55:48 +08:00
|
|
|
if (NOT LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "libunwind must be built as either a shared or static library.")
|
|
|
|
endif()
|
|
|
|
|
2016-06-02 09:19:52 +08:00
|
|
|
# Check that we can build with 32 bits if requested.
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
|
|
|
|
if (LIBUNWIND_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
|
|
|
|
message(STATUS "Building 32 bits executables and libraries.")
|
|
|
|
endif()
|
|
|
|
elseif(LIBUNWIND_BUILD_32_BITS)
|
|
|
|
message(FATAL_ERROR "LIBUNWIND_BUILD_32_BITS=ON is not supported on this platform.")
|
|
|
|
endif()
|
|
|
|
|
2019-01-30 07:01:08 +08:00
|
|
|
option(LIBUNWIND_HERMETIC_STATIC_LIBRARY
|
|
|
|
"Do not export any symbols from the static library." OFF)
|
|
|
|
|
2015-04-25 09:46:35 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Configure System
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
${CMAKE_MODULE_PATH})
|
|
|
|
|
2018-06-30 04:27:40 +08:00
|
|
|
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
2019-05-23 05:08:33 +08:00
|
|
|
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++)
|
|
|
|
if(LIBCXX_LIBDIR_SUBDIR)
|
|
|
|
string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
|
|
|
|
string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
|
|
|
|
endif()
|
2018-06-30 04:27:40 +08:00
|
|
|
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
|
2017-07-19 05:30:18 +08:00
|
|
|
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
|
2017-07-19 05:30:18 +08:00
|
|
|
else()
|
2017-08-08 08:37:59 +08:00
|
|
|
set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
|
2017-07-19 05:30:18 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBUNWIND_INSTALL_PREFIX "" CACHE STRING "Define libunwind destination prefix.")
|
2017-07-11 09:12:09 +08:00
|
|
|
|
2016-06-02 09:02:10 +08:00
|
|
|
set(LIBUNWIND_C_FLAGS "")
|
|
|
|
set(LIBUNWIND_CXX_FLAGS "")
|
|
|
|
set(LIBUNWIND_COMPILE_FLAGS "")
|
|
|
|
set(LIBUNWIND_LINK_FLAGS "")
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2019-10-12 06:22:29 +08:00
|
|
|
# Include macros for adding and removing libunwind flags.
|
|
|
|
include(HandleLibunwindFlags)
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#===============================================================================
|
2016-06-02 09:02:10 +08:00
|
|
|
|
2019-10-12 06:22:29 +08:00
|
|
|
# Get required flags.
|
2016-06-02 09:02:10 +08:00
|
|
|
add_target_flags_if(LIBUNWIND_BUILD_32_BITS "-m32")
|
[CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.
libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.
This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.
Differential Revision: https://reviews.llvm.org/D57670
llvm-svn: 353084
2019-02-05 04:02:26 +08:00
|
|
|
|
|
|
|
if(LIBUNWIND_TARGET_TRIPLE)
|
|
|
|
add_target_flags("--target=${LIBUNWIND_TARGET_TRIPLE}")
|
|
|
|
elseif(CMAKE_CXX_COMPILER_TARGET)
|
|
|
|
set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
|
|
|
endif()
|
|
|
|
if(LIBUNWIND_GCC_TOOLCHAIN)
|
|
|
|
add_target_flags("--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}")
|
|
|
|
elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
|
|
|
set(LIBUNWIND_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
|
|
|
|
endif()
|
|
|
|
if(LIBUNWIND_SYSROOT)
|
|
|
|
add_target_flags("--sysroot=${LIBUNWIND_SYSROOT}")
|
|
|
|
elseif(CMAKE_SYSROOT)
|
|
|
|
set(LIBUNWIND_SYSROOT "${CMAKE_SYSROOT}")
|
|
|
|
endif()
|
2016-06-02 09:02:10 +08:00
|
|
|
|
2017-12-06 04:48:05 +08:00
|
|
|
if (LIBUNWIND_TARGET_TRIPLE)
|
|
|
|
set(TARGET_TRIPLE "${LIBUNWIND_TARGET_TRIPLE}")
|
|
|
|
endif()
|
|
|
|
|
2016-06-02 09:02:10 +08:00
|
|
|
# Configure compiler.
|
|
|
|
include(config-ix)
|
|
|
|
|
2018-09-05 04:57:50 +08:00
|
|
|
if (LIBUNWIND_USE_COMPILER_RT AND NOT LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
|
2017-04-12 10:28:07 +08:00
|
|
|
list(APPEND LIBUNWIND_LINK_FLAGS "-rtlib=compiler-rt")
|
|
|
|
endif()
|
|
|
|
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags_if_supported(-Werror=return-type)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
|
|
|
# Get warning flags
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags_if_supported(-W)
|
|
|
|
add_compile_flags_if_supported(-Wall)
|
|
|
|
add_compile_flags_if_supported(-Wchar-subscripts)
|
|
|
|
add_compile_flags_if_supported(-Wconversion)
|
|
|
|
add_compile_flags_if_supported(-Wmismatched-tags)
|
|
|
|
add_compile_flags_if_supported(-Wmissing-braces)
|
|
|
|
add_compile_flags_if_supported(-Wnewline-eof)
|
|
|
|
add_compile_flags_if_supported(-Wno-unused-function)
|
|
|
|
add_compile_flags_if_supported(-Wshadow)
|
|
|
|
add_compile_flags_if_supported(-Wshorten-64-to-32)
|
|
|
|
add_compile_flags_if_supported(-Wsign-compare)
|
|
|
|
add_compile_flags_if_supported(-Wsign-conversion)
|
|
|
|
add_compile_flags_if_supported(-Wstrict-aliasing=2)
|
|
|
|
add_compile_flags_if_supported(-Wstrict-overflow=4)
|
|
|
|
add_compile_flags_if_supported(-Wunused-parameter)
|
|
|
|
add_compile_flags_if_supported(-Wunused-variable)
|
|
|
|
add_compile_flags_if_supported(-Wwrite-strings)
|
|
|
|
add_compile_flags_if_supported(-Wundef)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2020-08-01 01:44:02 +08:00
|
|
|
add_compile_flags_if_supported(-Wno-suggest-override)
|
|
|
|
|
2020-10-24 03:51:21 +08:00
|
|
|
if (WIN32)
|
|
|
|
# The headers lack matching dllexport attributes (_LIBUNWIND_EXPORT);
|
|
|
|
# silence the warning instead of cluttering the headers (which aren't
|
|
|
|
# necessarily the ones that the callers will use anyway) with the
|
|
|
|
# attributes.
|
|
|
|
add_compile_flags_if_supported(-Wno-dll-attribute-on-redeclaration)
|
|
|
|
endif()
|
|
|
|
|
2015-04-25 09:46:35 +08:00
|
|
|
if (LIBUNWIND_ENABLE_WERROR)
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags_if_supported(-Werror)
|
|
|
|
add_compile_flags_if_supported(-WX)
|
2015-04-25 09:46:35 +08:00
|
|
|
else()
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags_if_supported(-Wno-error)
|
|
|
|
add_compile_flags_if_supported(-WX-)
|
2015-04-25 09:46:35 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBUNWIND_ENABLE_PEDANTIC)
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags_if_supported(-pedantic)
|
2015-04-25 09:46:35 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Get feature flags.
|
|
|
|
# Exceptions
|
|
|
|
# Catches C++ exceptions only and tells the compiler to assume that extern C
|
|
|
|
# functions never throw a C++ exception.
|
2019-10-12 06:22:29 +08:00
|
|
|
add_cxx_compile_flags_if_supported(-fstrict-aliasing)
|
|
|
|
add_cxx_compile_flags_if_supported(-EHsc)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2019-12-06 22:26:35 +08:00
|
|
|
# Don't run the linker in this CMake check.
|
|
|
|
#
|
|
|
|
# The reason why this was added is that when building libunwind for
|
|
|
|
# ARM Linux, we need to pass the -funwind-tables flag in order for it to
|
|
|
|
# work properly with ARM EHABI.
|
|
|
|
#
|
|
|
|
# However, when performing CMake checks, adding this flag causes the check
|
|
|
|
# to produce a false negative, because the compiler generates calls
|
|
|
|
# to __aeabi_unwind_cpp_pr0, which is defined in libunwind itself,
|
|
|
|
# which isn't built yet, so the linker complains about undefined symbols.
|
|
|
|
#
|
|
|
|
# This leads to libunwind not being built with this flag, which makes
|
|
|
|
# libunwind quite useless in this setup.
|
|
|
|
set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
2019-10-12 09:50:57 +08:00
|
|
|
add_compile_flags_if_supported(-funwind-tables)
|
2019-12-06 22:26:35 +08:00
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE})
|
|
|
|
|
|
|
|
if (LIBUNWIND_USES_ARM_EHABI AND NOT LIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG)
|
|
|
|
message(SEND_ERROR "The -funwind-tables flag must be supported "
|
|
|
|
"because this target uses ARM Exception Handling ABI")
|
|
|
|
endif()
|
|
|
|
|
2019-10-12 06:22:29 +08:00
|
|
|
add_cxx_compile_flags_if_supported(-fno-exceptions)
|
|
|
|
add_cxx_compile_flags_if_supported(-fno-rtti)
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2019-01-30 06:26:18 +08:00
|
|
|
# Ensure that we don't depend on C++ standard library.
|
2019-10-12 09:50:57 +08:00
|
|
|
if (LIBUNWIND_HAS_NOSTDINCXX_FLAG)
|
2019-10-12 06:22:29 +08:00
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -nostdinc++)
|
|
|
|
# Remove -stdlib flags to prevent them from causing an unused flag warning.
|
2020-10-13 22:05:00 +08:00
|
|
|
string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
2019-10-12 06:22:29 +08:00
|
|
|
string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
endif()
|
2019-01-30 06:26:18 +08:00
|
|
|
|
2015-04-25 09:46:35 +08:00
|
|
|
# Assert
|
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
|
|
|
if (LIBUNWIND_ENABLE_ASSERTIONS)
|
|
|
|
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
|
|
|
|
if (NOT MSVC)
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags(-D_DEBUG)
|
2016-08-09 01:56:28 +08:00
|
|
|
endif()
|
2015-04-25 09:46:35 +08:00
|
|
|
|
|
|
|
# On Release builds cmake automatically defines NDEBUG, so we
|
|
|
|
# explicitly undefine it:
|
|
|
|
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags(-UNDEBUG)
|
2016-08-09 01:56:28 +08:00
|
|
|
endif()
|
2015-04-25 09:46:35 +08:00
|
|
|
else()
|
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags(-DNDEBUG)
|
2016-08-09 01:56:28 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2016-05-25 20:36:34 +08:00
|
|
|
# Cross-unwinding
|
|
|
|
if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING)
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags(-D_LIBUNWIND_IS_NATIVE_ONLY)
|
2016-08-09 01:56:28 +08:00
|
|
|
endif()
|
2016-05-25 20:36:34 +08:00
|
|
|
|
2016-09-28 18:57:15 +08:00
|
|
|
# Threading-support
|
|
|
|
if (NOT LIBUNWIND_ENABLE_THREADS)
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags(-D_LIBUNWIND_HAS_NO_THREADS)
|
2016-09-28 18:57:15 +08:00
|
|
|
endif()
|
|
|
|
|
2016-07-07 18:55:39 +08:00
|
|
|
# ARM WMMX register support
|
|
|
|
if (LIBUNWIND_ENABLE_ARM_WMMX)
|
|
|
|
# __ARM_WMMX is a compiler pre-define (as per the ACLE 2.0). Clang does not
|
|
|
|
# define this macro for any supported target at present. Therefore, here we
|
|
|
|
# provide the option to explicitly enable support for WMMX registers in the
|
|
|
|
# unwinder.
|
2019-10-12 06:22:29 +08:00
|
|
|
add_compile_flags(-D__ARM_WMMX)
|
2016-08-09 01:56:28 +08:00
|
|
|
endif()
|
2016-07-07 18:55:39 +08:00
|
|
|
|
2020-07-29 18:39:41 +08:00
|
|
|
if(LIBUNWIND_IS_BAREMETAL)
|
|
|
|
add_compile_definitions(_LIBUNWIND_IS_BAREMETAL)
|
|
|
|
endif()
|
|
|
|
|
2020-08-19 03:05:07 +08:00
|
|
|
if(LIBUNWIND_USE_FRAME_HEADER_CACHE)
|
|
|
|
add_compile_definitions(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
|
|
|
|
endif()
|
|
|
|
|
2020-11-11 17:58:41 +08:00
|
|
|
if(LIBUNWIND_REMEMBER_HEAP_ALLOC)
|
|
|
|
add_compile_definitions(_LIBUNWIND_REMEMBER_HEAP_ALLOC)
|
|
|
|
endif()
|
|
|
|
|
2015-04-25 09:46:35 +08:00
|
|
|
# This is the _ONLY_ place where add_definitions is called.
|
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2016-08-09 01:56:28 +08:00
|
|
|
endif()
|
2015-04-25 09:46:35 +08:00
|
|
|
|
2017-11-29 16:21:12 +08:00
|
|
|
# Disable DLL annotations on Windows for static builds.
|
|
|
|
if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
|
|
|
|
add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
|
|
|
|
endif()
|
|
|
|
|
2019-05-30 12:40:21 +08:00
|
|
|
if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
|
2019-11-30 22:13:56 +08:00
|
|
|
if (LIBUNWIND_HAS_DL_LIB)
|
|
|
|
add_definitions(-D_LIBUNWIND_LINK_DL_LIB)
|
|
|
|
endif()
|
|
|
|
if (LIBUNWIND_HAS_PTHREAD_LIB)
|
|
|
|
add_definitions(-D_LIBUNWIND_LINK_PTHREAD_LIB)
|
|
|
|
endif()
|
2019-05-30 12:40:21 +08:00
|
|
|
endif()
|
|
|
|
|
2015-04-25 09:46:35 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup Source Code
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
include_directories(include)
|
|
|
|
|
|
|
|
add_subdirectory(src)
|
2017-03-28 23:21:43 +08:00
|
|
|
|
|
|
|
if (LIBUNWIND_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
2017-07-06 23:20:12 +08:00
|
|
|
|
2018-08-03 13:51:31 +08:00
|
|
|
if (EXISTS ${LLVM_CMAKE_PATH})
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|