From 3d1b382f626ef72187adbc68ad4a5c64afd5f513 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 10 May 2023 18:13:09 +0200 Subject: CMakeLists: Fix ppoll() feature detection. Use check_cxx_symbol_exists() instead of check_symbol_exists() for the subtle reason explained in the comment added in this patch. Change-Id: Id949b8f2c7af39eeef3a848d3bdbc7639432f38a --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd32ab1..ac62a49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,16 @@ else() if(NOT NINJA_FORCE_PSELECT) # Check whether ppoll() is usable on the target platform. # Set -DUSE_PPOLL=1 if this is the case. - include(CheckSymbolExists) - check_symbol_exists(ppoll poll.h HAVE_PPOLL) + # + # NOTE: Use check_cxx_symbol_exists() instead of check_symbol_exists() + # because on Linux, only exposes the symbol when _GNU_SOURCE + # is defined. + # + # Both g++ and clang++ define the symbol by default, because the C++ + # standard library headers require it, but *not* gcc and clang, which + # are used by check_symbol_exists(). + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(ppoll poll.h HAVE_PPOLL) if(HAVE_PPOLL) add_compile_definitions(USE_PPOLL=1) endif() -- cgit v1.2.1