diff --git a/CMakeLists.txt b/CMakeLists.txt index fd32ab10bf..ac62a490b3 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()