f8599a6aacfd8825ed7ea98cf2b3408fff4330c2
[quassel.git] / cmake / FindExecInfo.cmake
1 # Set up execinfo
2
3 # The problem with this library is that it is built-in in the Linux glib,
4 # while on systems like FreeBSD, it is installed separately and thus needs to be linked to.
5 # Therefore, we search for the header to see if the it's available in the first place.
6 # If it is available, we try to locate the library to figure out whether it is built-in or not.
7
8 find_path(EXECINFO_INCLUDES "execinfo.h")
9
10 if(EXECINFO_INCLUDES)
11   # We found the header file's include dir.
12
13   # Now determine if it's built-in or not, by searching the library file.
14   find_library(EXECINFO_LIBRARIES "execinfo")
15
16   if(NOT EXECINFO_LIBRARIES)
17     # Built-in, no further action is needed
18     set(EXECINFO_LIBRARIES "")
19     message(STATUS "Found execinfo (built-in)")
20   else()
21     # It's an external library.
22     message(STATUS "Found execinfo: ${EXECINFO_LIBRARIES}")
23   endif()
24
25   set(EXECINFO_FOUND true)
26
27 endif()