#!/bin/bash # Define the build directory BUILD_DIR="build" # Remove the existing build directory if it exists if [ -d "$BUILD_DIR" ]; then echo "Removing existing build directory..." rm -rf "$BUILD_DIR" fi # Create a new build directory echo "Creating build directory..." mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" || exit # Run CMake to configure the project echo "Configuring the project with CMake..." cmake .. # Check if CMake configuration was successful if [ $? -ne 0 ]; then echo "CMake configuration failed!" exit 1 fi # Build the project echo "Building the project..." make # Check if the build was successful if [ $? -ne 0 ]; then echo "Build failed!" exit 1 fi echo "Build completed successfully!"