-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·39 lines (31 loc) · 1.07 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·39 lines (31 loc) · 1.07 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
#!/bin/bash
set -e
# Detect base directories
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$SRC_DIR/build"
# Auto-detect compilers and tools for maximum speed
LAUNCHER_FLAGS=""
LINKER_FLAGS=""
GENERATOR_FLAGS=""
if command -v clang++ &> /dev/null; then
export CC=clang
export CXX=clang++
fi
if command -v ccache &> /dev/null; then
LAUNCHER_FLAGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi
if command -v mold &> /dev/null; then
LINKER_FLAGS="-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=mold"
fi
if command -v ninja &> /dev/null; then
GENERATOR_FLAGS="-G Ninja"
fi
# Configure if build directory doesn't exist or we want to force reconfigure
cmake $GENERATOR_FLAGS -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release $LAUNCHER_FLAGS $LINKER_FLAGS
# Build using Ninja if available, otherwise fallback to standard parallel CMake build
if command -v ninja &> /dev/null; then
ninja -C "$BUILD_DIR"
else
CORES=$(nproc 2>/dev/null || echo 4)
cmake --build "$BUILD_DIR" -j "$CORES"
fi