mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 13:50:11 +00:00
libunwind: add new build logic
This replicates most of the build infrastructure from libc++abi ported to libunwind. This allows building libunwind without requiring libc++abi. llvm-svn: 235795
This commit is contained in:
parent
a121d08ff8
commit
c5d132b336
225
libunwind/CMakeLists.txt
Normal file
225
libunwind/CMakeLists.txt
Normal file
@ -0,0 +1,225 @@
|
||||
#===============================================================================
|
||||
# Setup Project
|
||||
#===============================================================================
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
|
||||
if (POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
||||
endif()
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
project(libunwind)
|
||||
|
||||
# Rely on llvm-config.
|
||||
set(CONFIG_OUTPUT)
|
||||
find_program(LLVM_CONFIG "llvm-config")
|
||||
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)
|
||||
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
|
||||
set(CONFIG_COMMAND ${LLVM_CONFIG} "--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_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
|
||||
set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
|
||||
else ()
|
||||
message(FATAL_ERROR "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(FATAL_ERROR "Not found: ${LLVM_CMAKE_PATH}")
|
||||
endif ()
|
||||
|
||||
set(PACKAGE_NAME libunwind)
|
||||
set(PACKAGE_VERSION 3.7.0svn)
|
||||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
|
||||
|
||||
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 ()
|
||||
|
||||
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 ()
|
||||
|
||||
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_MAIN_SRC_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "Path to LLVM source tree")
|
||||
set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# Setup CMake Options
|
||||
#===============================================================================
|
||||
|
||||
# Define options.
|
||||
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_WERROR "Fail and stop if a warning is triggered." OFF)
|
||||
option(LIBUNWIND_ENABLE_SHARED "Build libunwind as a shared library." ON)
|
||||
|
||||
set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.")
|
||||
set(LIBUNWIND_SYSROOT "" CACHE STRING "Sysroot for cross compiling.")
|
||||
|
||||
#===============================================================================
|
||||
# Configure System
|
||||
#===============================================================================
|
||||
|
||||
# Add path for custom modules
|
||||
set(CMAKE_MODULE_PATH
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
||||
${CMAKE_MODULE_PATH})
|
||||
|
||||
# Configure compiler.
|
||||
include(config-ix)
|
||||
|
||||
set(LIBUNWIND_COMPILER ${CMAKE_CXX_COMPILER})
|
||||
set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
|
||||
|
||||
#===============================================================================
|
||||
# Setup Compiler Flags
|
||||
#===============================================================================
|
||||
|
||||
# Get required flags.
|
||||
macro(append_if list condition var)
|
||||
if (${condition})
|
||||
list(APPEND ${list} ${var})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(LIBUNWIND_C_FLAGS "")
|
||||
set(LIBUNWIND_CXX_FLAGS "")
|
||||
set(LIBUNWIND_COMPILE_FLAGS "")
|
||||
set(LIBUNWIND_LINK_FLAGS "")
|
||||
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WERROR_FLAG -Werror=return-type)
|
||||
|
||||
# Get warning flags
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_W_FLAG -W)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WALL_FLAG -Wall)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WCHAR_SUBSCRIPTS_FLAG -Wchar-subscripts)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WCONVERSION_FLAG -Wconversion)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WMISMATCHED_TAGS_FLAG -Wmismatched-tags)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WMISSING_BRACES_FLAG -Wmissing-braces)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WNEWLINE_EOF_FLAG -Wnewline-eof)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WNO_UNUSED_FUNCTION_FLAG -Wno-unused-function)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSHADOW_FLAG -Wshadow)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSHORTEN_64_TO_32_FLAG -Wshorten-64-to-32)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSIGN_COMPARE_FLAG -Wsign-compare)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSIGN_CONVERSION_FLAG -Wsign-conversion)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSTRICT_ALIASING_FLAG -Wstrict-aliasing=2)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WSTRICT_OVERFLOW_FLAG -Wstrict-overflow=4)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WUNUSED_PARAMETER_FLAG -Wunused-parameter)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WUNUSED_VARIABLE_FLAG -Wunused-variable)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WUNDEF_FLAG -Wundef)
|
||||
|
||||
if (LIBUNWIND_ENABLE_WERROR)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WERROR_FLAG -Werror)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WX_FLAG -WX)
|
||||
else()
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WNO_ERROR_FLAG -Wno-error)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_NO_WX_FLAG -WX-)
|
||||
endif()
|
||||
|
||||
if (LIBUNWIND_ENABLE_PEDANTIC)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_PEDANTIC_FLAG -pedantic)
|
||||
endif()
|
||||
|
||||
# Get feature flags.
|
||||
# Exceptions
|
||||
# Catches C++ exceptions only and tells the compiler to assume that extern C
|
||||
# functions never throw a C++ exception.
|
||||
append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_FSTRICT_ALIASING_FLAG -fstrict-aliasing)
|
||||
append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_EHSC_FLAG -EHsc)
|
||||
|
||||
append_if(LIBUNWIND_C_FLAGS LIBUNWIND_HAS_FUNWIND_TABLES -funwind-tables)
|
||||
|
||||
# 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)
|
||||
endif ()
|
||||
|
||||
# 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)
|
||||
endif ()
|
||||
else()
|
||||
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
||||
list(APPEND LIBUNWIND_COMPILE_FLAGS -DNDEBUG)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# This is the _ONLY_ place where add_definitions is called.
|
||||
if (MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif ()
|
||||
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_TARGET_TRIPLE
|
||||
"-target ${LIBUNWIND_TARGET_TRIPLE}")
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_GCC_TOOLCHAIN
|
||||
"-gcc-toolchain ${LIBUNWIND_GCC_TOOLCHAIN}")
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_SYSROOT
|
||||
"--sysroot=${LIBUNWIND_SYSROOT}")
|
||||
|
||||
#===============================================================================
|
||||
# Setup Source Code
|
||||
#===============================================================================
|
||||
|
||||
include_directories(include)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
45
libunwind/cmake/config-ix.cmake
Normal file
45
libunwind/cmake/config-ix.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
# Check compiler flags
|
||||
check_c_compiler_flag(-funwind-tables LIBUNWIND_HAS_FUNWIND_TABLES)
|
||||
check_cxx_compiler_flag(-fPIC LIBUNWIND_HAS_FPIC_FLAG)
|
||||
check_cxx_compiler_flag(-fno-exceptions LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG)
|
||||
check_cxx_compiler_flag(-fno-rtti LIBUNWIND_HAS_NO_RTTI_FLAG)
|
||||
check_cxx_compiler_flag(-fstrict-aliasing LIBUNWIND_HAS_FSTRICT_ALIASING_FLAG)
|
||||
check_cxx_compiler_flag(-nodefaultlibs LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
|
||||
check_cxx_compiler_flag(-nostdinc++ LIBUNWIND_HAS_NOSTDINCXX_FLAG)
|
||||
check_cxx_compiler_flag(-Wall LIBUNWIND_HAS_WALL_FLAG)
|
||||
check_cxx_compiler_flag(-W LIBUNWIND_HAS_W_FLAG)
|
||||
check_cxx_compiler_flag(-Wno-unused-function LIBUNWIND_HAS_WNO_UNUSED_FUNCTION_FLAG)
|
||||
check_cxx_compiler_flag(-Wunused-variable LIBUNWIND_HAS_WUNUSED_VARIABLE_FLAG)
|
||||
check_cxx_compiler_flag(-Wunused-parameter LIBUNWIND_HAS_WUNUSED_PARAMETER_FLAG)
|
||||
check_cxx_compiler_flag(-Wstrict-aliasing LIBUNWIND_HAS_WSTRICT_ALIASING_FLAG)
|
||||
check_cxx_compiler_flag(-Wstrict-overflow LIBUNWIND_HAS_WSTRICT_OVERFLOW_FLAG)
|
||||
check_cxx_compiler_flag(-Wwrite-strings LIBUNWIND_HAS_WWRITE_STRINGS_FLAG)
|
||||
check_cxx_compiler_flag(-Wchar-subscripts LIBUNWIND_HAS_WCHAR_SUBSCRIPTS_FLAG)
|
||||
check_cxx_compiler_flag(-Wmismatched-tags LIBUNWIND_HAS_WMISMATCHED_TAGS_FLAG)
|
||||
check_cxx_compiler_flag(-Wmissing-braces LIBUNWIND_HAS_WMISSING_BRACES_FLAG)
|
||||
check_cxx_compiler_flag(-Wshorten-64-to-32 LIBUNWIND_HAS_WSHORTEN_64_TO_32_FLAG)
|
||||
check_cxx_compiler_flag(-Wsign-conversion LIBUNWIND_HAS_WSIGN_CONVERSION_FLAG)
|
||||
check_cxx_compiler_flag(-Wsign-compare LIBUNWIND_HAS_WSIGN_COMPARE_FLAG)
|
||||
check_cxx_compiler_flag(-Wshadow LIBUNWIND_HAS_WSHADOW_FLAG)
|
||||
check_cxx_compiler_flag(-Wconversion LIBUNWIND_HAS_WCONVERSION_FLAG)
|
||||
check_cxx_compiler_flag(-Wnewline-eof LIBUNWIND_HAS_WNEWLINE_EOF_FLAG)
|
||||
check_cxx_compiler_flag(-Wundef LIBUNWIND_HAS_WUNDEF_FLAG)
|
||||
check_cxx_compiler_flag(-pedantic LIBUNWIND_HAS_PEDANTIC_FLAG)
|
||||
check_cxx_compiler_flag(-Werror LIBUNWIND_HAS_WERROR_FLAG)
|
||||
check_cxx_compiler_flag(-Wno-error LIBUNWIND_HAS_WNO_ERROR_FLAG)
|
||||
check_cxx_compiler_flag(/WX LIBUNWIND_HAS_WX_FLAG)
|
||||
check_cxx_compiler_flag(/WX- LIBUNWIND_HAS_NO_WX_FLAG)
|
||||
check_cxx_compiler_flag(/EHsc LIBUNWIND_HAS_EHSC_FLAG)
|
||||
check_cxx_compiler_flag(/EHs- LIBUNWIND_HAS_NO_EHS_FLAG)
|
||||
check_cxx_compiler_flag(/EHa- LIBUNWIND_HAS_NO_EHA_FLAG)
|
||||
check_cxx_compiler_flag(/GR- LIBUNWIND_HAS_NO_GR_FLAG)
|
||||
|
||||
check_library_exists(c printf "" LIBUNWIND_HAS_C_LIB)
|
||||
check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)
|
||||
check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)
|
||||
|
@ -21,22 +21,21 @@ set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
|
||||
LANGUAGE C)
|
||||
|
||||
set(LIBUNWIND_HEADERS
|
||||
AddressSpace.hpp
|
||||
assembly.h
|
||||
CompactUnwinder.hpp
|
||||
config.h
|
||||
dwarf2.h
|
||||
DwarfInstructions.hpp
|
||||
DwarfParser.hpp
|
||||
libunwind_ext.h
|
||||
Registers.hpp
|
||||
UnwindCursor.hpp
|
||||
unwind_ext.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/libunwind.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/unwind.h
|
||||
)
|
||||
AddressSpace.hpp
|
||||
assembly.h
|
||||
CompactUnwinder.hpp
|
||||
config.h
|
||||
dwarf2.h
|
||||
DwarfInstructions.hpp
|
||||
DwarfParser.hpp
|
||||
libunwind_ext.h
|
||||
Registers.hpp
|
||||
UnwindCursor.hpp
|
||||
unwind_ext.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/libunwind.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/unwind.h)
|
||||
|
||||
append_if(LIBCXXABI_HEADERS APPLE
|
||||
append_if(LIBUNWIND_HEADERS APPLE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/mach-o/compact_unwind_encoding.h")
|
||||
|
||||
if (MSVC_IDE)
|
||||
@ -54,65 +53,57 @@ if (LIBUNWIND_ENABLE_SHARED)
|
||||
add_library(unwind SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
|
||||
else()
|
||||
add_library(unwind STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
|
||||
endif()
|
||||
|
||||
include_directories("${LIBCXXABI_LIBCXX_INCLUDES}")
|
||||
endif ()
|
||||
|
||||
# Generate library list.
|
||||
set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})
|
||||
append_if(libraries LIBCXXABI_HAS_C_LIB c)
|
||||
append_if(libraries LIBCXXABI_HAS_DL_LIB dl)
|
||||
append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread)
|
||||
set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES})
|
||||
append_if(libraries LIBUNWIND_HAS_C_LIB c)
|
||||
append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
|
||||
append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
|
||||
|
||||
target_link_libraries(unwind ${libraries})
|
||||
|
||||
# Setup flags.
|
||||
append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FPIC_FLAG -fPIC)
|
||||
append_if(LIBCXXABI_LINK_FLAGS LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_NO_RTTI_FLAG -fno-rtti)
|
||||
|
||||
set(LIBUNWIND_COMPILE_FLAGS)
|
||||
append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_RTTI_FLAG -fno-rtti)
|
||||
if ( LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG AND LIBCXXABI_HAS_FUNWIND_TABLES )
|
||||
append_if(LIBUNWIND_LINK_FLAGS LIBUNWIND_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
|
||||
|
||||
if (LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG AND LIBUNWIND_HAS_FUNWIND_TABLES)
|
||||
list(APPEND LIBUNWIND_COMPILE_FLAGS -fno-exceptions)
|
||||
list(APPEND LIBUNWIND_COMPILE_FLAGS -funwind-tables)
|
||||
elseif( LIBUNWIND_ENABLE_SHARED )
|
||||
message(FATAL_ERROR "Compiler doesn't support generation of unwind tables "
|
||||
"if exception support is disabled. Building libunwind "
|
||||
"DSO with runtime dependency on libcxxabi is not "
|
||||
"supported.")
|
||||
elseif (LIBUNWIND_ENABLE_SHARED)
|
||||
message(FATAL_ERROR
|
||||
"Compiler doesn't support generation of unwind tables if exception "
|
||||
"support is disabled. Building libunwind DSO with runtime dependency "
|
||||
"on C++ ABI library is not supported.")
|
||||
endif()
|
||||
|
||||
set(LIBCXXABI_UNWINDER_NAME "unwind")
|
||||
if (APPLE)
|
||||
list(APPEND LIBUNWIND_COMPILE_FLAGS "-U__STRICT_ANSI__")
|
||||
list(APPEND LIBUNWIND_LINK_FLAGS
|
||||
"-compatibility_version 1"
|
||||
"-install_name /usr/lib/libunwind.1.dylib")
|
||||
|
||||
if ( APPLE )
|
||||
if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
|
||||
list(APPEND LIBCXXABI_COMPILE_FLAGS "-U__STRICT_ANSI__")
|
||||
list(APPEND LIBCXXABI_LINK_FLAGS
|
||||
"-compatibility_version 1"
|
||||
"-current_version ${LIBCXXABI_VERSION}"
|
||||
"-install_name /usr/lib/lib${LIBCXXABI_UNWINDER_NAME}.1.dylib"
|
||||
"/usr/lib/libSystem.B.dylib")
|
||||
else()
|
||||
list(APPEND LIBCXXABI_LINK_FLAGS
|
||||
"-compatibility_version 1"
|
||||
"-install_name /usr/lib/lib${LIBCXXABI_UNWINDER_NAME}.1.dylib")
|
||||
endif()
|
||||
endif()
|
||||
if (CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6")
|
||||
list(APPEND LIBUNWIND_LINK_FLAGS
|
||||
"-current_version ${LIBUNWIND_VERSION}"
|
||||
"/usr/lib/libSystem.B.dylib")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
string(REPLACE ";" " " LIBCXXABI_COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}")
|
||||
string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
|
||||
string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}")
|
||||
string(REPLACE ";" " " LIBUNWIND_LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}")
|
||||
|
||||
set_target_properties(unwind
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS} ${LIBUNWIND_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}"
|
||||
OUTPUT_NAME "${LIBCXXABI_UNWINDER_NAME}"
|
||||
VERSION "1.0"
|
||||
SOVERSION "1"
|
||||
)
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${CMAKE_COMPILE_FLAGS} ${LIBUNWIND_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${CMAKE_LINK_FLAGS} ${LIBUNWIND_LINK_FLAGS}"
|
||||
OUTPUT_NAME "unwind"
|
||||
VERSION "1.0"
|
||||
SOVERSION "1")
|
||||
|
||||
install(TARGETS unwind
|
||||
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
)
|
||||
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user