From 0af1852eed2f4f893878e2b1656e6a7819ea0c41 Mon Sep 17 00:00:00 2001 From: Pierre Pfister Date: Mon, 20 Aug 2018 14:59:45 +0200 Subject: Detect support for memfd_create at compilation Compilation was failing on systems without memfd_create. This uses check_c_source_compiles to check whether the memfd_create function is available on the system. Credits to Damjan for his help troubleshooting. Change-Id: I136d9504d7978e3a09438d0d76b2de1042702b2c Signed-off-by: Pierre Pfister --- src/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 790d6a20477..84971c77ac6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,7 +118,20 @@ find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) -add_definitions(-DHAVE_MEMFD_CREATE -DVPP_API_TEST_BUILTIN=1) +add_definitions(-DVPP_API_TEST_BUILTIN=1) + +############################################################################## +# Check for memfd_create headers and libs +############################################################################## +check_c_source_compiles(" + #define _GNU_SOURCE + #include + int main() { return memfd_create (\"/dev/false\", 0); } +" HAVE_MEMFD_CREATE) + +if (HAVE_MEMFD_CREATE) + add_definitions(-DHAVE_MEMFD_CREATE) +endif() ############################################################################## # API -- cgit 1.2.3-korg