-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·50 lines (40 loc) · 1.5 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·50 lines (40 loc) · 1.5 KB
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
#!/bin/bash
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No color
# Directories
BUILD_DIR="build"
# CMake options
CMAKE_BUILD_TYPE="Debug" # Change to "Release" if needed
BUILD_TESTS=ON # Enable or disable tests
echo -e "${GREEN}--- Configuring and building with CMake ---${NC}"
# Install Conan dependencies if tests are enabled
if [ "$BUILD_TESTS" = "ON" ]; then
echo -e "${GREEN}--- Installing dependencies with Conan ---${NC}"
if ! conan install . --output-folder="$BUILD_DIR" --build=missing -s build_type="$CMAKE_BUILD_TYPE"; then
echo -e "${RED}Conan dependency installation failed.${NC}"
exit 1
fi
fi
# Configure and generate build files using CMake
if ! cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -DBUILD_TESTS="$BUILD_TESTS" -DCMAKE_TOOLCHAIN_FILE="$BUILD_DIR/build/Debug/generators/conan_toolchain.cmake" .; then
echo -e "${RED}CMake configuration failed.${NC}"
exit 1
fi
# Build the project
if ! cmake --build "$BUILD_DIR" --config "$CMAKE_BUILD_TYPE"; then
echo -e "${RED}Build failed.${NC}"
exit 1
fi
echo -e "${GREEN}--- Build completed successfully ---${NC}"
# Run tests if enabled
if [ "$BUILD_TESTS" = "ON" ]; then
echo -e "${GREEN}--- Running tests ---${NC}"
if ! ctest --test-dir "$BUILD_DIR" --output-on-failure; then
echo -e "${RED}Some tests failed.${NC}"
exit 1
fi
echo -e "${GREEN}All tests passed successfully.${NC}"
fi
echo -e "${GREEN}Script completed successfully.${NC}"