summaryrefslogtreecommitdiffstats
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2018-08-20 14:59:45 +0200
committerDamjan Marion <dmarion@me.com>2018-08-20 14:43:01 +0000
commit0af1852eed2f4f893878e2b1656e6a7819ea0c41 (patch)
tree933016f19d4126c60f4896209a3f7f90a7bf9763 /src/CMakeLists.txt
parent2ddfe7524001270654c2027378b05f10e527eb5c (diff)
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 <ppfister@cisco.com>
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt15
1 files changed, 14 insertions, 1 deletions
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 <sys/mman.h>
+ int main() { return memfd_create (\"/dev/false\", 0); }
+" HAVE_MEMFD_CREATE)
+
+if (HAVE_MEMFD_CREATE)
+ add_definitions(-DHAVE_MEMFD_CREATE)
+endif()
##############################################################################
# API