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 ${CMAKE_CURRENT_SOURCE_DIR}/../include/libunwind.h 36 ${CMAKE_CURRENT_SOURCE_DIR}/../include/unwind.h) 37 38append_if(LIBUNWIND_HEADERS APPLE 39 "${CMAKE_CURRENT_SOURCE_DIR}/../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 58# Generate library list. 59set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES}) 60append_if(libraries LIBUNWIND_HAS_C_LIB c) 61append_if(libraries LIBUNWIND_HAS_DL_LIB dl) 62append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread) 63 64target_link_libraries(unwind ${libraries}) 65 66# Setup flags. 67append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC) 68append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NO_RTTI_FLAG -fno-rtti) 69 70append_if(LIBUNWIND_LINK_FLAGS LIBUNWIND_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) 71 72if (LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG AND LIBUNWIND_HAS_FUNWIND_TABLES) 73 list(APPEND LIBUNWIND_COMPILE_FLAGS -fno-exceptions) 74 list(APPEND LIBUNWIND_COMPILE_FLAGS -funwind-tables) 75elseif (LIBUNWIND_ENABLE_SHARED) 76 message(FATAL_ERROR 77 "Compiler doesn't support generation of unwind tables if exception " 78 "support is disabled. Building libunwind DSO with runtime dependency " 79 "on C++ ABI library is not supported.") 80endif() 81 82if (APPLE) 83 list(APPEND LIBUNWIND_COMPILE_FLAGS "-U__STRICT_ANSI__") 84 list(APPEND LIBUNWIND_LINK_FLAGS 85 "-compatibility_version 1" 86 "-install_name /usr/lib/libunwind.1.dylib") 87 88 if (CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6") 89 list(APPEND LIBUNWIND_LINK_FLAGS 90 "-current_version ${LIBUNWIND_VERSION}" 91 "/usr/lib/libSystem.B.dylib") 92 endif () 93endif () 94 95string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") 96string(REPLACE ";" " " LIBUNWIND_CXX_FLAGS "${LIBUNWIND_CXX_FLAGS}") 97string(REPLACE ";" " " LIBUNWIND_LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}") 98 99set_target_properties(unwind 100 PROPERTIES 101 COMPILE_FLAGS "${CMAKE_COMPILE_FLAGS} ${LIBUNWIND_COMPILE_FLAGS}" 102 LINK_FLAGS "${CMAKE_LINK_FLAGS} ${LIBUNWIND_LINK_FLAGS}" 103 OUTPUT_NAME "unwind" 104 VERSION "1.0" 105 SOVERSION "1") 106set_property(SOURCE ${LIBUNWIND_CXX_SOURCES} 107 APPEND_STRING PROPERTY COMPILE_FLAGS "${LIBUNWIND_CXX_FLAGS}") 108 109install(TARGETS unwind 110 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} 111 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) 112 113