diff --git a/build.sh b/build.sh index b08fff2..19a095f 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ [ ! -d build ] && mkdir build echo "Configuring..." -cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./Release +cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./Release $@ if [ $? -ne 0 ]; then echo "CMake failed. Aborting." @@ -10,9 +10,13 @@ else echo "CMake succeeded." fi -echo "Building..." +if [ -z "$THREADS" ]; then + THREADS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +fi + +echo "Building with $THREADS threads..." cd build -make +make -j$THREADS if [ $? -ne 0 ]; then echo "Build failed. Aborting." diff --git a/install.sh b/install.sh index 5e512eb..1c05180 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ [ ! -d build ] && mkdir build echo "Configuring..." -cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ +cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ $@ if [ $? -ne 0 ]; then echo "CMake failed. Aborting." @@ -10,9 +10,13 @@ else echo "CMake succeeded." fi -echo "Building..." +if [ -z "$THREADS" ]; then + THREADS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +fi + +echo "Building with $THREADS threads..." cd build -make +make -j$THREADS if [ $? -ne 0 ]; then echo "Build failed. Aborting."