if [ -z "$1" ]; then
    echo "Error: Invalid Argument"
    echo "Usage: $0 <executable_name>"
    exit 1
fi

if [ ! -d "./build" ]; then
    echo "Creating build directory..."
    mkdir build
fi

echo ">>> Building C++ Project <<<"
cd ./build
cmake -DOUTPUT_NAME=$1 ..
echo ">>> Compiling... <<<"
make
if [ $? -ne 0 ]; then
    echo "Error: Build failed"
    exit 1
fi
cp ./bin/$1 ../
echo ">>> Build Complete <<<"
echo ">>> Executable: $1 <<<"