source: icGREP/icgrep-devel/icgrep/cmake/FindLibunwind.cmake @ 5782

Last change on this file since 5782 was 5487, checked in by nmedfort, 2 years ago

Bug fix for FindLibunwind?.cmake

File size: 1.3 KB
Line 
1# Find the libunwind library
2#
3#  LIBUNWIND_FOUND       - True if libunwind was found.
4#  LIBUNWIND_LIBRARIES   - The libraries needed to use libunwind
5#  LIBUNWIND_INCLUDE_DIR - Location of unwind.h and libunwind.h
6 
7FIND_PATH(LIBUNWIND_INCLUDE_DIR libunwind.h)
8
9SET(LIBUNWIND_FOUND TRUE)
10if(NOT LIBUNWIND_INCLUDE_DIR)
11  SET(LIBUNWIND_FOUND FALSE)
12elseif(NOT EXISTS "${LIBUNWIND_INCLUDE_DIR}/unwind.h")
13  SET(LIBUNWIND_FOUND FALSE)
14  SET(LIBUNWIND_INCLUDE_DIR "")
15endif()
16 
17FIND_LIBRARY(LIBUNWIND_GENERIC_LIBRARY "unwind")
18
19if (NOT LIBUNWIND_GENERIC_LIBRARY)
20  SET(LIBUNWIND_FOUND FALSE)
21endif ()
22SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_GENERIC_LIBRARY})
23
24# For some reason, we have to link to two libunwind shared object files:
25# one arch-specific and one not.
26if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
27  SET(LIBUNWIND_ARCH "arm")
28elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
29  SET(LIBUNWIND_ARCH "x86_64")
30elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
31  SET(LIBUNWIND_ARCH "x86")
32endif()
33
34if (LIBUNWIND_ARCH)
35  FIND_LIBRARY(LIBUNWIND_SPECIFIC_LIBRARY "unwind-${LIBUNWIND_ARCH}")
36  if (NOT LIBUNWIND_SPECIFIC_LIBRARY)
37    SET(LIBUNWIND_FOUND FALSE)
38  endif ()
39  SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY})
40endif(LIBUNWIND_ARCH)
41
42MARK_AS_ADVANCED(LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIR)
Note: See TracBrowser for help on using the repository browser.