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.
8 find_path(EXECINFO_INCLUDES "execinfo.h")
10 if(EXECINFO_INCLUDES STREQUAL "EXECINFO_INCLUDES-NOTFOUND")
11 set(EXECINFO_INCLUDES "")
12 else(EXECINFO_INCLUDES STREQUAL "EXECINFO_INCLUDES-NOTFOUND")
13 # We found the header file's include dir.
15 # Now determine if it's built-in or not, by searching the library file.
16 find_library(EXECINFO_LIBRARIES "execinfo")
18 if(EXECINFO_LIBRARIES STREQUAL "EXECINFO_LIBRARIES-NOTFOUND")
19 # Built-in, no further action is needed
20 set(EXECINFO_LIBRARIES "")
21 message(STATUS "Found execinfo (built-in)")
22 else(EXECINFO_LIBRARIES STREQUAL "EXECINFO_LIBRARIES-NOTFOUND")
23 # It's an external library.
24 message(STATUS "Found execinfo: ${EXECINFO_LIBRARIES}")
25 endif(EXECINFO_LIBRARIES STREQUAL "EXECINFO_LIBRARIES-NOTFOUND")
27 set(EXECINFO_FOUND true)
29 endif(EXECINFO_INCLUDES STREQUAL "EXECINFO_INCLUDES-NOTFOUND")