Skip to content

Commit

Permalink
CMakeLists: Fix ppoll() feature detection.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
digit-android authored and digit-google committed May 10, 2023
1 parent adf9bdd commit 3d1b382
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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, <poll.h> 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()
Expand Down

0 comments on commit 3d1b382

Please sign in to comment.