diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2020-02-20 10:50:08 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2020-02-20 10:50:08 +0300 |
commit | b9d9c6501559e61f0fdd68e83b7cec8f231c4498 (patch) | |
tree | 69252cc7f3760b5bce396128939e8402ae45cb2c /CMakeLists.txt | |
parent | 967180e8b44ea1ef54857cce72c7706b6aa7114b (diff) | |
download | bdwgc-b9d9c6501559e61f0fdd68e83b7cec8f231c4498.tar.gz |
Detect presence of getcontext and dl_iterate_phdr in CMake script
Previously, presence of these system functions were done by configure
only.
* CMakeLists.txt (CheckFunctionExists): Include.
* CMakeLists.txt (getcontext, dl_iterate_phdr): Check function exists
(to set HAVE_GETCONTEXT and HAVE_DL_ITERATE_PHDR variables,
respectively).
* CMakeLists.txt [!HAVE_GETCONTEXT] (NO_GETCONTEXT): Define macro.
* CMakeLists.txt [HAVE_DL_ITERATE_PHDR] (HAVE_DL_ITERATE_PHDR):
Likewise.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e9ed12e2..87c3bb7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ else() project(gc C) endif() +include(CheckFunctionExists) include(CTest) # Customize the build by passing "-D<option_name>=ON|OFF" in the command line. @@ -305,6 +306,18 @@ if (DEFINED CFLAGS_EXTRA) add_compile_options(${CFLAGS_EXTRA}) endif() +# Check for getcontext (uClibc can be configured without it, for example). +check_function_exists(getcontext HAVE_GETCONTEXT) +if (NOT HAVE_GETCONTEXT) + add_definitions("-DNO_GETCONTEXT") +endif() + +# Check whether dl_iterate_phdr exists (as a strong symbol). +check_function_exists(dl_iterate_phdr HAVE_DL_ITERATE_PHDR) +if (HAVE_DL_ITERATE_PHDR) + add_definitions("-DHAVE_DL_ITERATE_PHDR") +endif() + add_library(gc ${SRC}) if (enable_threads) target_link_libraries(gc PRIVATE ${THREADDLLIBS}) |