diff --git a/scripts/build_android.sh b/scripts/build_android.sh index b2a6836d9d6..c7c843eac16 100755 --- a/scripts/build_android.sh +++ b/scripts/build_android.sh @@ -48,6 +48,11 @@ cd $BUILD_ROOT CMAKE_ARGS=() +# If Ninja is installed, prefer it to Make +if [ -x "$(command -v ninja)" ]; then + CMAKE_ARGS+=("-GNinja") +fi + # Use locally built protoc because we'll build libprotobuf for the # target architecture and need an exact version match. CMAKE_ARGS+=("-DCAFFE2_CUSTOM_PROTOC_EXECUTABLE=$CAFFE2_ROOT/build_host_protoc/bin/protoc") diff --git a/scripts/build_host_protoc.sh b/scripts/build_host_protoc.sh index 5ae7fc87daa..77944a3f0f9 100755 --- a/scripts/build_host_protoc.sh +++ b/scripts/build_host_protoc.sh @@ -22,6 +22,11 @@ CMAKE_ARGS=() CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT") CMAKE_ARGS+=("-Dprotobuf_BUILD_TESTS=OFF") +# If Ninja is installed, prefer it to Make +if [ -x "$(command -v ninja)" ]; then + CMAKE_ARGS+=("-GNinja") +fi + while true; do case "$1" in --other-flags) @@ -45,7 +50,7 @@ fi cmake "$CAFFE2_ROOT/third_party/protobuf/cmake" ${CMAKE_ARGS[@]} if [ "$(uname)" == 'Darwin' ]; then - make "-j$(sysctl -n hw.ncpu)" install + cmake --build . -- "-j$(sysctl -n hw.ncpu)" install else - make "-j$(nproc)" install + cmake --build . -- "-j$(nproc)" install fi diff --git a/scripts/build_local.sh b/scripts/build_local.sh index 9d40a6a18f5..20f0fb38acc 100755 --- a/scripts/build_local.sh +++ b/scripts/build_local.sh @@ -11,6 +11,11 @@ CAFFE2_ROOT="$( cd "$(dirname "$0")"/.. ; pwd -P)" CMAKE_ARGS=() +# If Ninja is installed, prefer it to Make +if [ -x "$(command -v ninja)" ]; then + CMAKE_ARGS+=("-GNinja") +fi + # Use ccache if available (this path is where Homebrew installs ccache symlinks) if [ "$(uname)" == 'Darwin' ]; then CCACHE_WRAPPER_PATH=/usr/local/opt/ccache/libexec