Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a5f46376ed2d2f9cfd439c9cd3f64ba3f300fbd7
[simgrid.git] / tools / cmake / Modules / FindLibunwind.cmake
1 if(PROCESSOR_x86_64)
2   find_library(PATH_LIBUNWIND_LIB
3     NAMES unwind-x86_64
4     HINTS
5     $ENV{SIMGRID_LIBUNWIND_LIBRARY_PATH}
6     $ENV{LD_LIBRARY_PATH}
7     $ENV{LIBUNWIND_LIBRARY_PATH}
8     PATH_SUFFIXES lib/ GnuWin32/lib lib/system
9     PATHS
10     /opt
11     /opt/local
12     /opt/csw
13     /sw
14     /usr)
15 endif()
16
17 if(NOT PATH_LIBUNWIND_LIB)
18   find_library(PATH_LIBUNWIND_LIB
19     NAMES unwind
20     HINTS
21     $ENV{SIMGRID_LIBUNWIND_LIBRARY_PATH}
22     $ENV{LD_LIBRARY_PATH}
23     $ENV{LIBUNWIND_LIBRARY_PATH}
24     PATH_SUFFIXES lib/ GnuWin32/lib lib/system
25     PATHS
26     /opt
27     /opt/local
28     /opt/csw
29     /sw
30     /usr
31     /usr/lib/)
32 endif()
33
34 find_path(PATH_LIBUNWIND_H "libunwind.h"
35   HINTS
36   $ENV{SIMGRID_LIBUNWIND_LIBRARY_PATH}
37   $ENV{LD_LIBRARY_PATH}
38   $ENV{LIBUNWIND_LIBRARY_PATH}
39   PATH_SUFFIXES include/ GnuWin32/include
40   PATHS
41   /opt
42   /opt/local
43   /opt/csw
44   /sw
45   /usr)
46
47 message(STATUS "Looking for libunwind.h")
48 if(PATH_LIBUNWIND_H)
49   message(STATUS "Looking for libunwind.h - found")
50 else()
51   message(STATUS "Looking for libunwind.h - not found")
52 endif()
53
54 message(STATUS "Looking for libunwind")
55 if(PATH_LIBUNWIND_LIB)
56   message(STATUS "Looking for libunwind - found")
57 else()
58   message(STATUS "Looking for libunwind - not found")
59 endif()
60
61 if(PATH_LIBUNWIND_LIB AND PATH_LIBUNWIND_H)
62   string(REGEX REPLACE "/libunwind.*[.]${LIB_EXE}$" "" PATH_LIBUNWIND_LIB "${PATH_LIBUNWIND_LIB}")
63   string(REGEX REPLACE "/libunwind.h"               "" PATH_LIBUNWIND_H   "${PATH_LIBUNWIND_H}")
64       
65   include_directories(${PATH_LIBUNWIND_H})
66   link_directories(${PATH_LIBUNWIND_LIB})
67   
68 else()
69   message(FATAL_ERROR "Please either install the libunwind7-dev package (or equivalent) or turn off the model-checking option of SimGrid.")
70 endif()
71
72 mark_as_advanced(PATH_LIBDW_H)
73 mark_as_advanced(PATH_LIBDW_LIB)
74 mark_as_advanced(PATH_LIBUNWIND_LIB)
75 mark_as_advanced(PATH_LIBUNWIND_H)