summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2023-04-19 18:57:11 +0200
committerDavid 'Digit' Turner <digit+github@google.com>2023-04-21 19:31:18 +0200
commit63415a419815d844149557aa16fa8a0f72b0c7e6 (patch)
tree2f6c9828e6938af8f4ba587a72582733cb7c74ee
parentc266b21674171dfb39d10872bec6ac493665cc5d (diff)
downloadninja-63415a419815d844149557aa16fa8a0f72b0c7e6.tar.gz
Enable ppoll() usage when available.
This patch modifies the CMakeLists.txt file to probe for ppoll() on the target system, and define -DUSE_PPOLL=1 if it is available. This can be disabled by setting -DNINJA_FORCE_PSELECT=ON when invoking CMake. This matches the default behavior of the configure.py script (and its `--force-pselect` option). Note that there is no noticeable performance difference before build commands are launched, so this change is very hard to benchmark properly. Fix for https://github.com/ninja-build/ninja/issues/1821
-rw-r--r--CMakeLists.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98f7948..fd32ab1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ include(CheckSymbolExists)
include(CheckIPOSupported)
option(NINJA_BUILD_BINARY "Build ninja binary" ON)
+option(NINJA_FORCE_PSELECT "Use pselect() even on platforms that provide ppoll()" OFF)
project(ninja CXX)
@@ -35,6 +36,16 @@ else()
if(flag_color_diag)
add_compile_options(-fdiagnostics-color)
endif()
+
+ 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)
+ if(HAVE_PPOLL)
+ add_compile_definitions(USE_PPOLL=1)
+ endif()
+ endif()
endif()
# --- optional re2c