diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-06-02 15:08:10 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2021-06-02 15:08:10 (GMT) |
commit | 54c5759471895f820735c232c36e81af96201912 (patch) | |
tree | d990081cce424f283109f6445a8536aaf12a3dd8 | |
parent | c573f6b8b23593f46a08616b76325d3ce0175002 (diff) | |
download | Ninja-54c5759471895f820735c232c36e81af96201912.zip Ninja-54c5759471895f820735c232c36e81af96201912.tar.gz Ninja-54c5759471895f820735c232c36e81af96201912.tar.bz2 |
cmake: use `check_symbol_exists` for browse support
Just because `unistd.h` exists does not mean it has the APIs that are
needed. This occurs when cross-compiling using Fedora's packaged MinGW
toolchain.
-rw-r--r-- | CMakeLists.txt | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8de69e8..bc02c4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -include(CheckIncludeFileCXX) +include(CheckSymbolExists) include(CheckIPOSupported) project(ninja) @@ -73,10 +73,15 @@ function(check_platform_supports_browse_mode RESULT) endif() # Now check availability of the unistd header - check_include_file_cxx(unistd.h PLATFORM_HAS_UNISTD_HEADER) - set(${RESULT} "${PLATFORM_HAS_UNISTD_HEADER}" PARENT_SCOPE) - if(NOT PLATFORM_HAS_UNISTD_HEADER) - message(WARNING "browse feature omitted due to missing unistd.h") + check_symbol_exists(fork "unistd.h" HAVE_FORK) + check_symbol_exists(pipe "unistd.h" HAVE_PIPE) + set(browse_supported 0) + if (HAVE_FORK AND HAVE_PIPE) + set(browse_supported 1) + endif () + set(${RESULT} "${browse_supported}" PARENT_SCOPE) + if(NOT browse_supported) + message(WARNING "browse feature omitted due to missing `fork` and `pipe` functions") endif() endfunction() |