Skip to content

Commit f671819

Browse files
build: support build with libunwind on osx (#162)
macOS provides a libunwind in SDK, so we can skip the library search process. --------- Co-authored-by: Jeremy Rifkin <[email protected]>
1 parent 231960d commit f671819

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

CMakeLists.txt

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -523,26 +523,28 @@ if(CPPTRACE_UNWIND_WITH_LIBUNWIND)
523523
endif()
524524
endif()
525525
if(NOT libunwind_FOUND)
526-
# set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
527-
# set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS ON)
528-
find_path(LIBUNWIND_INCLUDE_DIRS NAMES "libunwind.h")
529-
find_library(LIBUNWIND NAMES unwind libunwind libunwind8 libunwind.so.8 REQUIRED PATHS "/usr/lib/x86_64-linux-gnu/")
530-
if(LIBUNWIND)
531-
set(libunwind_FOUND TRUE)
532-
endif()
533-
if(NOT libunwind_FOUND)
534-
# message(FATAL_ERROR "Unable to locate libunwind")
535-
# Try to link with it if it's where it should be
536-
# This path can be entered if libunwind was installed via the system package manager, sometimes. I probably messed
537-
# up the find_library above.
538-
set(LIBUNWIND_LDFLAGS "-lunwind")
539-
endif()
540-
if(NOT LIBUNWIND_LDFLAGS)
541-
set(LIBUNWIND_LDFLAGS "${LIBUNWIND}")
526+
if (NOT APPLE)
527+
# set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
528+
# set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS ON)
529+
find_path(LIBUNWIND_INCLUDE_DIRS NAMES "libunwind.h")
530+
find_library(LIBUNWIND NAMES unwind libunwind libunwind8 libunwind.so.8 REQUIRED PATHS "/usr/lib/x86_64-linux-gnu/")
531+
if(LIBUNWIND)
532+
set(libunwind_FOUND TRUE)
533+
endif()
534+
if(NOT libunwind_FOUND)
535+
# message(FATAL_ERROR "Unable to locate libunwind")
536+
# Try to link with it if it's where it should be
537+
# This path can be entered if libunwind was installed via the system package manager, sometimes. I probably messed
538+
# up the find_library above.
539+
set(LIBUNWIND_LDFLAGS "-lunwind")
540+
endif()
541+
if(NOT LIBUNWIND_LDFLAGS)
542+
set(LIBUNWIND_LDFLAGS "${LIBUNWIND}")
543+
endif()
544+
target_compile_options(${target_name} PRIVATE ${LIBUNWIND_CFLAGS_OTHER})
545+
target_include_directories(${target_name} PRIVATE ${LIBUNWIND_INCLUDE_DIRS})
546+
target_link_libraries(${target_name} PRIVATE ${LIBUNWIND_LDFLAGS})
542547
endif()
543-
target_compile_options(${target_name} PRIVATE ${LIBUNWIND_CFLAGS_OTHER})
544-
target_include_directories(${target_name} PRIVATE ${LIBUNWIND_INCLUDE_DIRS})
545-
target_link_libraries(${target_name} PRIVATE ${LIBUNWIND_LDFLAGS})
546548
target_compile_definitions(${target_name} PUBLIC CPPTRACE_UNWIND_WITH_LIBUNWIND UNW_LOCAL_ONLY)
547549
endif()
548550
endif()

0 commit comments

Comments
 (0)