-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathcmake.sh
More file actions
executable file
·55 lines (43 loc) · 1.5 KB
/
cmake.sh
File metadata and controls
executable file
·55 lines (43 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
51
52
53
54
#!/usr/bin/env bash
set -euo pipefail
# --- Configuration ---
BUILD_DIR="build"
PROFILE="default" # Change to your Conan profile name if needed
BUILD_TYPE="Release" # Or "Debug"
# --- Determine default generator ---
OS_NAME="$(uname -s)"
if [[ "$OS_NAME" == "Darwin" ]]; then
DEFAULT_GENERATOR="Xcode"
else [[ "$OS_NAME" == "Linux" ]];
DEFAULT_GENERATOR="Ninja"
fi
# Allow override via env var or first CLI argument
GENERATOR="${GENERATOR:-${1:-$DEFAULT_GENERATOR}}"
echo "Using CMake generator: $GENERATOR"
mkdir -p "${BUILD_DIR}"
# --- Step 1: Install Conan dependencies ---
echo "Installing Conan Debug build type dependencies..."
conan install . \
--profile "${PROFILE}" \
--build=missing \
--output-folder="${BUILD_DIR}" \
--settings build_type="Debug"
echo "Installing Conan RelWithDebInfo build type dependencies..."
conan install . \
--profile "${PROFILE}" \
--build=missing \
--output-folder="${BUILD_DIR}" \
--settings build_type="RelWithDebInfo"
echo "Installing Conan Release build type dependencies..."
conan install . \
--profile "${PROFILE}" \
--build=missing \
--output-folder="${BUILD_DIR}" \
--settings build_type="Release"
# --- Step 3: Run CMake ---
echo "Generating project with ${GENERATOR}..."
cmake -S . -B "${BUILD_DIR}" \
-G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_TOOLCHAIN_FILE=${BUILD_DIR}/${BUILD_TYPE}/generators/conan_toolchain.cmake
echo "✅ Project generated in ${BUILD_DIR} using ${GENERATOR}"