Detect number of cores in build script

This commit is contained in:
Wojciech Bartnik
2022-04-02 18:53:06 +02:00
parent 6f04f52f5c
commit 141b83228c
+8 -2
View File
@@ -83,6 +83,13 @@ else
BUILD_DIR="build"
fi
CORES_COUNT=4
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
CORES_COUNT="$(nproc)"
elif [[ "$OSTYPE" == "darwin"* ]]; then
CORES_COUNT="$(sysctl -n hw.physicalcpu)"
fi
# Strict errors. Any non-zero return exits this script
set -e
@@ -90,6 +97,5 @@ mkdir -p ${BUILD_DIR}
pushd ${BUILD_DIR}
cmake $CMAKE_ARGS ..
make -j4 $MAKE_OPT
make -j$CORES_COUNT $MAKE_OPT
popd