Files
OpenSuperClone/build.sh
T

60 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
for arg in "$@"; do
if [ "$arg" = "clean" ]; then
./clean.sh
break
fi
done
CMAKE_OPTIONS=""
CMAKE_BUILD_TYPE=Release
CMAKE_INSTALL_PREFIX=./Release
for arg in "$@"; do
if [ "$arg" = "debug" ]; then
CMAKE_OPTIONS="-DDEBUG=ON"
CMAKE_BUILD_TYPE=Debug
CMAKE_INSTALL_PREFIX=./Debug
fi
done
[ ! -d build ] && mkdir build
echo "Configuring for $CMAKE_BUILD_TYPE..."
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX $CMAKE_OPTIONS
if [ $? -ne 0 ]; then
echo "CMake failed. Aborting."
exit 1
else
echo "CMake succeeded."
fi
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 -j$THREADS
if [ $? -ne 0 ]; then
echo "Build failed. Aborting."
exit 1
else
echo "Build succeeded."
fi
echo "Installing OpenSuperClone to $CMAKE_INSTALL_PREFIX..."
make install
if [ $? -ne 0 ]; then
echo "Install failed. Aborting."
exit 1
else
echo "Install succeeded."
fi
echo "Done."