-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_run.sh
57 lines (45 loc) · 1.24 KB
/
build_and_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Check if the script is run as root
if [[ "$EUID" -ne 0 ]]; then
echo "Please run this script as root (use sudo)."
exit 1
fi
# Function to install a package if not already installed
install_if_needed() {
if ! dpkg -s "$1" >/dev/null 2>&1; then
echo "Installing $1..."
sudo apt-get install -y "$1"
else
echo "$1 is already installed."
fi
}
# Update package list
echo "Updating package list..."
sudo apt-get update
# Check and install required packages
install_if_needed "libgl1-mesa-dev"
install_if_needed "qt6-base-dev"
install_if_needed "qt6-tools-dev"
install_if_needed "qt6-tools-dev-tools"
install_if_needed "cmake"
install_if_needed "g++"
# Navigate to the project directory
cd "$(dirname "$0")"
# Create and navigate to the build directory
mkdir -p build
cd build
# Run CMake to configure the project
if ! command_exists cmake; then
echo "CMake is not installed, installing CMake..."
sudo apt-get install -y cmake
fi
echo "Configuring the project with CMake..."
cmake ../COS3711-02-04/
# Build the project
echo "Building the project..."
make
# Run the application
echo "Running the application..."
./COS3711-02-04
# Print completion message
echo "Build and run completed successfully."