From d3ee55fe1b6d09795c419f12a3ad6f7d0b5df6b4 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Mon, 26 Oct 2015 20:25:32 +1300 Subject: build: Add check for posix_spawn functions These are usually found in librt. On some systems clock_gettime is also in librt so checking for it was implicitly satisfying the requirement for the posix_spawn functions. On newer systems (glibc >2.17 for example) clock_gettime is also found in libc so AC_SEARCH_LIBS() decides that it is not necessary to add -lrt to LIBS. Add an explicit check for posix_spawnp() to decide if -lrt is necessary. --- CMakeLists.txt | 3 ++- configure.ac | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 899d142..179630e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,7 +144,8 @@ endif() cmake_pop_check_state() check_library_exists(rt clock_gettime "time.h" CLOCK_GETTIME_NEEDS_LIBRT) -if (CLOCK_GETTIME_NEEDS_LIBRT) +check_library_exists(rt posix_spawnp "spawn.h" POSIX_SPAWNP_NEEDS_LIBRT) +if (CLOCK_GETTIME_NEEDS_LIBRT OR POSIX_SPAWNP_NEEDS_LIBRT) set(LIBRT rt) endif() diff --git a/configure.ac b/configure.ac index 2c0eda8..ce094b8 100644 --- a/configure.ac +++ b/configure.ac @@ -102,6 +102,7 @@ AC_SEARCH_LIBS([socket], [socket], [], [AC_MSG_ERROR([cannot find socket library (library with socket symbol)])], [-lnsl])]) AC_SEARCH_LIBS([clock_gettime], [rt]) +AC_SEARCH_LIBS([posix_spawnp], [rt]) AC_MSG_CHECKING([if htonll is defined]) dnl # Check for htonll -- cgit v1.2.1