Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "libunwind 32bits: don't search the lib in itself but in its directory"
[simgrid.git] / tools / cmake / Modules / FindLibunwind.cmake
1 message(STATUS "Looking for libunwind")
2
3 if(PROCESSOR_x86_64)
4   find_library(PATH_LIBUNWIND_LIB
5     NAMES unwind-x86_64
6     HINTS
7     $ENV{SIMGRID_LIBUNWIND_LIBRARY_PATH}
8     $ENV{LD_LIBRARY_PATH}
9     $ENV{LIBUNWIND_LIBRARY_PATH}
10     PATH_SUFFIXES lib/ GnuWin32/lib lib/system
11     PATHS
12     /opt
13     /opt/local
14     /opt/csw
15     /sw
16     /usr)
17   message(STATUS "Looking for libunwind-x86_64 - found")
18 endif()
19
20 if(NOT PATH_LIBUNWIND_LIB)
21   find_library(PATH_LIBUNWIND_LIB
22     NAMES unwind
23     HINTS
24       $ENV{SIMGRID_LIBUNWIND_LIBRARY_PATH}
25       $ENV{LD_LIBRARY_PATH}
26       $ENV{LIBUNWIND_LIBRARY_PATH}
27       PATH_SUFFIXES lib/ GnuWin32/lib lib/system
28       PATHS
29       /opt
30       /opt/local
31       /opt/csw
32       /sw
33       /usr
34       /usr/lib/)
35       
36   # Mac OSX has a libunwind that is not the one we need, so double check
37   if (PATH_LIBUNWIND_LIB)
38     message(STATUS "Looking for libunwind - found")
39     CHECK_LIBRARY_EXISTS(unwind unw_init_local "${PATH_LIBUNWIND_LIB}" RIGHT_LIBUNWIND)
40     if (NOT RIGHT_LIBUNWIND)
41       message(STATUS "libunwind in ${PATH_LIBUNWIND_LIB} is unusable. Disable it.")
42       set(PATH_LIBUNWIND_LIB 0)
43     endif()
44     
45   else()
46     message(STATUS "Looking for libunwind - not found")
47   endif()
48
49 endif()
50
51 find_path(PATH_LIBUNWIND_H "libunwind.h"
52   HINTS
53   $ENV{SIMGRID_LIBUNWIND_LIBRARY_PATH}
54   $ENV{LD_LIBRARY_PATH}
55   $ENV{LIBUNWIND_LIBRARY_PATH}
56   PATH_SUFFIXES include/ GnuWin32/include
57   PATHS
58   /opt
59   /opt/local
60   /opt/csw
61   /sw
62   /usr)
63
64 message(STATUS "Looking for libunwind.h")
65 if(PATH_LIBUNWIND_H)
66   message(STATUS "Looking for libunwind.h - found")
67 else()
68   message(STATUS "Looking for libunwind.h - not found")
69 endif()
70
71 if(PATH_LIBUNWIND_LIB AND PATH_LIBUNWIND_H)
72   string(REGEX REPLACE "/libunwind.*[.]${LIB_EXE}$" "" PATH_LIBUNWIND_LIB "${PATH_LIBUNWIND_LIB}")
73   string(REGEX REPLACE "/libunwind.h"               "" PATH_LIBUNWIND_H   "${PATH_LIBUNWIND_H}")
74       
75   include_directories(${PATH_LIBUNWIND_H})
76   link_directories(${PATH_LIBUNWIND_LIB})
77   SET(HAVE_LIBUNWIND 1)
78 else()
79   SET(HAVE_LIBUNWIND 0)
80 endif()
81
82 mark_as_advanced(PATH_LIBDW_H)
83 mark_as_advanced(PATH_LIBDW_LIB)
84 mark_as_advanced(PATH_LIBUNWIND_LIB)
85 mark_as_advanced(PATH_LIBUNWIND_H)