1# Get sources 2 3set(LIBUNWIND_CXX_SOURCES 4 libunwind.cpp 5 Unwind-EHABI.cpp) 6append_if(LIBUNWIND_CXX_SOURCES APPLE Unwind_AppleExtras.cpp) 7 8set(LIBUNWIND_C_SOURCES 9 UnwindLevel1.c 10 UnwindLevel1-gcc-ext.c 11 Unwind-sjlj.c) 12set_source_files_properties(${LIBUNWIND_C_SOURCES} 13 PROPERTIES 14 COMPILE_FLAGS "-std=c99") 15 16set(LIBUNWIND_ASM_SOURCES 17 UnwindRegistersRestore.S 18 UnwindRegistersSave.S) 19set_source_files_properties(${LIBUNWIND_ASM_SOURCES} 20 PROPERTIES 21 LANGUAGE C) 22 23set(LIBUNWIND_HEADERS 24 AddressSpace.hpp 25 assembly.h 26 CompactUnwinder.hpp 27 config.h 28 dwarf2.h 29 DwarfInstructions.hpp 30 DwarfParser.hpp 31 libunwind_ext.h 32 Registers.hpp 33 UnwindCursor.hpp 34 unwind_ext.h 35 ../../include/libunwind.h 36 ../../include/unwind.h 37) 38 39append_if(LIBCXXABI_HEADERS APPLE ../../include/mach-o/compact_unwind_encoding.h) 40 41if (MSVC_IDE) 42 # Force them all into the headers dir on MSVC, otherwise they end up at 43 # project scope because they don't have extensions. 44 source_group("Header Files" FILES ${LIBUNWIND_HEADERS}) 45endif() 46 47set(LIBUNWIND_SOURCES 48 ${LIBUNWIND_CXX_SOURCES} 49 ${LIBUNWIND_C_SOURCES} 50 ${LIBUNWIND_ASM_SOURCES}) 51 52if (LIBUNWIND_ENABLE_SHARED) 53 add_library(unwind SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) 54else() 55 add_library(unwind STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) 56endif() 57 58include_directories("${LIBCXXABI_LIBCXX_INCLUDES}") 59 60# Generate library list. 61set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES}) 62append_if(libraries LIBCXXABI_HAS_C_LIB c) 63append_if(libraries LIBCXXABI_HAS_DL_LIB dl) 64append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread) 65 66target_link_libraries(unwind ${libraries}) 67 68# Setup flags. 69append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FPIC_FLAG -fPIC) 70append_if(LIBCXXABI_LINK_FLAGS LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) 71 72set(LIBUNWIND_COMPILE_FLAGS) 73append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_RTTI_FLAG -fno-rtti) 74if ( LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG AND LIBCXXABI_HAS_FUNWIND_TABLES ) 75 list(APPEND LIBUNWIND_COMPILE_FLAGS -fno-exceptions) 76 list(APPEND LIBUNWIND_COMPILE_FLAGS -funwind-tables) 77elseif( LIBUNWIND_ENABLE_SHARED ) 78 message(FATAL_ERROR "Compiler doesn't support generation of unwind tables " 79 "if exception support is disabled. Building libunwind " 80 "DSO with runtime dependency on libcxxabi is not " 81 "supported.") 82endif() 83 84set(LIBCXXABI_UNWINDER_NAME "unwind") 85 86if ( APPLE ) 87 if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) 88 list(APPEND LIBCXXABI_COMPILE_FLAGS "-U__STRICT_ANSI__") 89 list(APPEND LIBCXXABI_LINK_FLAGS 90 "-compatibility_version 1" 91 "-current_version ${LIBCXXABI_VERSION}" 92 "-install_name /usr/lib/lib${LIBCXXABI_UNWINDER_NAME}.1.dylib" 93 "/usr/lib/libSystem.B.dylib") 94 else() 95 list(APPEND LIBCXXABI_LINK_FLAGS 96 "-compatibility_version 1" 97 "-install_name /usr/lib/lib${LIBCXXABI_UNWINDER_NAME}.1.dylib") 98 endif() 99endif() 100 101string(REPLACE ";" " " LIBCXXABI_COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}") 102string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") 103string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}") 104 105set_target_properties(unwind 106 PROPERTIES 107 COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS} ${LIBUNWIND_COMPILE_FLAGS}" 108 LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" 109 OUTPUT_NAME "${LIBCXXABI_UNWINDER_NAME}" 110 VERSION "1.0" 111 SOVERSION "1" 112 ) 113 114install(TARGETS unwind 115 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 116 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} 117 ) 118