summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2020-02-27 01:22:07 +0300
committerIvan Maidanski <ivmai@mail.ru>2020-02-27 10:58:54 +0300
commit3a8028ff21fb89e00b9bff87f5216b4e657b666e (patch)
tree6dd4fd0f17e2be41c1befa1a53f4f16b3a7417cf /CMakeLists.txt
parent3b88c374a09f10fccf9f3195b900b53526ea1184 (diff)
downloadbdwgc-3a8028ff21fb89e00b9bff87f5216b4e657b666e.tar.gz
Detect dladdr() presence in CMake script
* CMakeLists.txt (CheckCSourceCompiles): Include module. * CMakeLists.txt: Check if C test code which calls dladdr() can be compiled and linked successfully; set HAVE_DLADDR variable accordingly. * CMakeLists.txt [HAVE_DLADDR] (HAVE_DLADDR): Define macro.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67ced5a0..c7ac9ced 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,7 @@ else()
endif()
include(CheckCCompilerFlag)
+include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckSymbolExists)
@@ -339,6 +340,17 @@ if (NOT HAVE_SIGSETJMP)
add_definitions("-DGC_NO_SIGSETJMP")
endif()
+# Check for dladdr (used for debugging).
+check_c_source_compiles("
+#define _GNU_SOURCE 1\n
+#include <dlfcn.h>\n
+int main(void) { Dl_info info; (void)dladdr(\"\", &info); return 0; }"
+ HAVE_DLADDR)
+if (HAVE_DLADDR)
+ # Define to use 'dladdr' function.
+ add_definitions("-DHAVE_DLADDR")
+endif()
+
add_library(gc ${SRC})
if (enable_threads)
target_link_libraries(gc PRIVATE ${THREADDLLIBS})