2015-04-25 01:46:35 +00:00
|
|
|
#===============================================================================
|
2015-08-06 23:31:37 +00:00
|
|
|
# Setup Project
|
2015-04-25 01:46:35 +00:00
|
|
|
#===============================================================================
|
|
|
|
|
2016-08-08 17:56:28 +00:00
|
|
|
cmake_minimum_required(VERSION 3.4.3)
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
if (POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
|
|
|
endif()
|
|
|
|
|
2017-04-12 02:28:07 +00:00
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
)
|
|
|
|
|
2015-04-25 01:46:35 +00:00
|
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
|
|
project(libunwind)
|
|
|
|
|
|
|
|
# Rely on llvm-config.
|
|
|
|
set(CONFIG_OUTPUT)
|
2016-11-08 23:02:49 +00:00
|
|
|
if(NOT LLVM_CONFIG_PATH)
|
|
|
|
find_program(LLVM_CONFIG_PATH "llvm-config")
|
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
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")
|
2016-11-08 23:02:49 +00:00
|
|
|
elseif(LLVM_CONFIG_PATH)
|
|
|
|
message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}")
|
|
|
|
set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} "--includedir" "--prefix" "--src-root")
|
2015-04-25 01:46:35 +00:00
|
|
|
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})
|
2016-08-08 17:56:28 +00:00
|
|
|
else()
|
2015-04-25 01:46:35 +00:00
|
|
|
string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
|
|
|
|
message(STATUS "${CONFIG_COMMAND_STR}")
|
|
|
|
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
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")
|
2017-01-09 23:27:04 +00:00
|
|
|
|
|
|
|
# --cmakedir is supported since llvm r291218 (4.0 release)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${LLVM_CONFIG_PATH} --cmakedir
|
|
|
|
RESULT_VARIABLE HAD_ERROR
|
2017-01-14 03:46:05 +00:00
|
|
|
OUTPUT_VARIABLE CONFIG_OUTPUT
|
|
|
|
ERROR_QUIET)
|
2017-01-09 23:27:04 +00:00
|
|
|
if(NOT HAD_ERROR)
|
2018-06-20 20:53:19 +00:00
|
|
|
string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH_FROM_LLVM_CONFIG)
|
|
|
|
file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH_FROM_LLVM_CONFIG}" LLVM_CMAKE_PATH)
|
2017-01-09 23:27:04 +00:00
|
|
|
else()
|
2018-06-20 20:53:19 +00:00
|
|
|
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")
|
2017-01-09 23:27:04 +00:00
|
|
|
endif()
|
2016-08-08 17:56:28 +00:00
|
|
|
else()
|
2018-08-03 05:51:31 +00:00
|
|
|
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.")
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
if (EXISTS ${LLVM_CMAKE_PATH})
|
2019-01-22 20:50:33 +00:00
|
|
|
# Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions.
|
|
|
|
set(LLVM_ENABLE_WARNINGS ON)
|
2015-04-25 01:46:35 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
|
|
|
|
include("${LLVM_CMAKE_PATH}/AddLLVM.cmake")
|
|
|
|
include("${LLVM_CMAKE_PATH}/HandleLLVMOptions.cmake")
|
2016-08-08 17:56:28 +00:00
|
|
|
else()
|
2018-08-03 05:51:31 +00:00
|
|
|
message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
set(PACKAGE_NAME libunwind)
|
2019-01-16 10:57:02 +00:00
|
|
|
set(PACKAGE_VERSION 9.0.0svn)
|
2015-04-25 01:46:35 +00:00
|
|
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
2015-08-05 04:01:47 +00:00
|
|
|
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
|
|
|
|
set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
|
2016-08-08 17:56:28 +00:00
|
|
|
else()
|
2015-04-25 01:46:35 +00:00
|
|
|
# Seek installed Lit.
|
|
|
|
find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
|
|
|
|
DOC "Path to lit.py")
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
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")
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
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")
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
|
|
|
else()
|
2015-04-25 01:46:35 +00:00
|
|
|
set(LLVM_INCLUDE_TESTS OFF)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
|
|
|
|
else()
|
|
|
|
set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup CMake Options
|
|
|
|
#===============================================================================
|
2018-07-24 23:42:51 +00:00
|
|
|
include(CMakeDependentOption)
|
2017-04-12 02:28:07 +00:00
|
|
|
include(HandleCompilerRT)
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
# Define options.
|
2016-06-02 01:02:10 +00:00
|
|
|
option(LIBUNWIND_BUILD_32_BITS "Build 32 bit libunwind" ${LLVM_BUILD_32_BITS})
|
2015-04-25 01:46:35 +00: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-08 22:55:48 +00:00
|
|
|
option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
|
2016-05-27 08:29:27 +00:00
|
|
|
option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF)
|
2016-07-07 10:55:39 +00:00
|
|
|
option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX registers." OFF)
|
2016-09-28 10:57:15 +00:00
|
|
|
option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
|
2019-05-13 18:45:03 +00:00
|
|
|
option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to refer to pthread functions." OFF)
|
2017-04-12 02:28:07 +00:00
|
|
|
option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
|
2017-03-28 15:21:43 +00:00
|
|
|
option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS})
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2017-08-08 00:37:59 +00:00
|
|
|
set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
|
|
|
"Define suffix of library directory name (32/64)")
|
2017-11-17 23:29:46 +00:00
|
|
|
option(LIBUNWIND_INSTALL_LIBRARY "Install the libunwind library." ON)
|
2018-07-24 23:27:51 +00: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 01:02:10 +00: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-27 18:40:04 +00: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.")
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2016-08-08 22:55:48 +00: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 01:19:52 +00: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-29 23:01:08 +00:00
|
|
|
option(LIBUNWIND_HERMETIC_STATIC_LIBRARY
|
|
|
|
"Do not export any symbols from the static library." OFF)
|
|
|
|
|
2015-04-25 01:46:35 +00:00
|
|
|
#===============================================================================
|
|
|
|
# Configure System
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
${CMAKE_MODULE_PATH})
|
|
|
|
|
|
|
|
set(LIBUNWIND_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2018-06-29 20:27:40 +00:00
|
|
|
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
|
|
|
${PACKAGE_VERSION})
|
|
|
|
|
|
|
|
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
2019-05-22 21:08:33 +00: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-29 20:27:40 +00:00
|
|
|
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
|
2017-07-18 21:30:18 +00:00
|
|
|
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
|
2019-05-22 21:08:33 +00:00
|
|
|
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
|
2017-07-18 21:30:18 +00:00
|
|
|
else()
|
2017-08-08 00:37:59 +00:00
|
|
|
set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
|
2019-05-22 21:08:33 +00:00
|
|
|
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
|
2017-07-18 21:30:18 +00: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 01:46:35 +00:00
|
|
|
|
2019-05-22 21:08:33 +00:00
|
|
|
set(LIBUNWIND_INSTALL_PREFIX "" CACHE STRING "Define libunwind destination prefix.")
|
2017-07-11 01:12:09 +00:00
|
|
|
|
2016-06-02 01:02:10 +00:00
|
|
|
set(LIBUNWIND_C_FLAGS "")
|
|
|
|
set(LIBUNWIND_CXX_FLAGS "")
|
|
|
|
set(LIBUNWIND_COMPILE_FLAGS "")
|
|
|
|
set(LIBUNWIND_LINK_FLAGS "")
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
# Get required flags.
|
2018-12-11 15:30:04 +00:00
|
|
|
macro(unwind_append_if list condition var)
|
2015-04-25 01:46:35 +00:00
|
|
|
if (${condition})
|
|
|
|
list(APPEND ${list} ${var})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2019-02-28 21:38:59 +00:00
|
|
|
macro(add_target_flags)
|
|
|
|
foreach(value ${ARGN})
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${value}")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${value}")
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS ${value})
|
|
|
|
list(APPEND LIBUNWIND_LINK_FLAGS ${value})
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(add_target_flags_if condition)
|
2016-06-02 01:02:10 +00:00
|
|
|
if (${condition})
|
2019-02-28 21:38:59 +00:00
|
|
|
add_target_flags(${ARGN})
|
2016-06-02 01:02:10 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
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-04 20:02:26 +00: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 01:02:10 +00:00
|
|
|
|
2017-12-05 20:48:05 +00:00
|
|
|
if (LIBUNWIND_TARGET_TRIPLE)
|
|
|
|
set(TARGET_TRIPLE "${LIBUNWIND_TARGET_TRIPLE}")
|
|
|
|
endif()
|
|
|
|
|
2016-06-02 01:02:10 +00:00
|
|
|
# Configure compiler.
|
|
|
|
include(config-ix)
|
|
|
|
|
2018-09-04 20:57:50 +00:00
|
|
|
if (LIBUNWIND_USE_COMPILER_RT AND NOT LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
|
2017-04-12 02:28:07 +00:00
|
|
|
list(APPEND LIBUNWIND_LINK_FLAGS "-rtlib=compiler-rt")
|
|
|
|
endif()
|
|
|
|
|
2016-06-02 01:02:10 +00:00
|
|
|
#===============================================================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#===============================================================================
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WERROR_FLAG -Werror=return-type)
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
# Get warning flags
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_W_FLAG -W)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WALL_FLAG -Wall)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WCHAR_SUBSCRIPTS_FLAG -Wchar-subscripts)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WCONVERSION_FLAG -Wconversion)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WMISMATCHED_TAGS_FLAG -Wmismatched-tags)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WMISSING_BRACES_FLAG -Wmissing-braces)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WNEWLINE_EOF_FLAG -Wnewline-eof)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WNO_UNUSED_FUNCTION_FLAG -Wno-unused-function)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSHADOW_FLAG -Wshadow)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSHORTEN_64_TO_32_FLAG -Wshorten-64-to-32)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSIGN_COMPARE_FLAG -Wsign-compare)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSIGN_CONVERSION_FLAG -Wsign-conversion)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSTRICT_ALIASING_FLAG -Wstrict-aliasing=2)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSTRICT_OVERFLOW_FLAG -Wstrict-overflow=4)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WUNUSED_PARAMETER_FLAG -Wunused-parameter)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WUNUSED_VARIABLE_FLAG -Wunused-variable)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WUNDEF_FLAG -Wundef)
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
if (LIBUNWIND_ENABLE_WERROR)
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WERROR_FLAG -Werror)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WX_FLAG -WX)
|
2015-04-25 01:46:35 +00:00
|
|
|
else()
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WNO_ERROR_FLAG -Wno-error)
|
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_NO_WX_FLAG -WX-)
|
2015-04-25 01:46:35 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBUNWIND_ENABLE_PEDANTIC)
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_PEDANTIC_FLAG -pedantic)
|
2015-04-25 01:46:35 +00: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.
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_FSTRICT_ALIASING_FLAG -fstrict-aliasing)
|
|
|
|
unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_EHSC_FLAG -EHsc)
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2018-12-11 15:30:04 +00:00
|
|
|
unwind_append_if(LIBUNWIND_C_FLAGS LIBUNWIND_HAS_FUNWIND_TABLES -funwind-tables)
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2019-01-29 22:26:18 +00:00
|
|
|
# Ensure that we don't depend on C++ standard library.
|
|
|
|
unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NOSTDINCXX_FLAG -nostdinc++)
|
|
|
|
|
2015-04-25 01:46:35 +00: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)
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -D_DEBUG)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
|
|
|
# On Release builds cmake automatically defines NDEBUG, so we
|
|
|
|
# explicitly undefine it:
|
|
|
|
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -UNDEBUG)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
else()
|
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -DNDEBUG)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2016-05-25 12:36:34 +00:00
|
|
|
# Cross-unwinding
|
|
|
|
if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING)
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_IS_NATIVE_ONLY)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2016-05-25 12:36:34 +00:00
|
|
|
|
2016-09-28 10:57:15 +00:00
|
|
|
# Threading-support
|
|
|
|
if (NOT LIBUNWIND_ENABLE_THREADS)
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS)
|
|
|
|
endif()
|
|
|
|
|
2016-07-07 10:55:39 +00: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.
|
|
|
|
list(APPEND LIBUNWIND_COMPILE_FLAGS -D__ARM_WMMX)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2016-07-07 10:55:39 +00:00
|
|
|
|
2015-04-25 01:46:35 +00:00
|
|
|
# This is the _ONLY_ place where add_definitions is called.
|
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2016-08-08 17:56:28 +00:00
|
|
|
endif()
|
2015-04-25 01:46:35 +00:00
|
|
|
|
2017-11-29 08:21:12 +00: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 04:40:21 +00:00
|
|
|
if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
|
|
|
|
add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
|
|
|
|
endif()
|
|
|
|
|
2015-04-25 01:46:35 +00:00
|
|
|
#===============================================================================
|
|
|
|
# Setup Source Code
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
include_directories(include)
|
|
|
|
|
|
|
|
add_subdirectory(src)
|
2017-03-28 15:21:43 +00:00
|
|
|
|
|
|
|
if (LIBUNWIND_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
2017-07-06 15:20:12 +00:00
|
|
|
|
2018-08-03 05:51:31 +00:00
|
|
|
if (EXISTS ${LLVM_CMAKE_PATH})
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|