-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from massenz/conan-v2
Updated the build script to use Conan v2
- Loading branch information
Showing
1 changed file
with
24 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2020-2023 AlertAvert.com. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Copyright (c) 2020-2024 AlertAvert.com. All rights reserved. | ||
# Author: Marco Massenzio ([email protected]) | ||
# | ||
|
||
# | ||
# Usage: build [build_type] | ||
# | ||
# Where `build_type` can be one of either `Release` or `Debug` (default) | ||
# Usage: build [--debug] [-h] | ||
|
||
set -eu | ||
|
||
if [[ -z ${COMMON_UTILS} || ! -d ${COMMON_UTILS} ]]; then | ||
echo "[ERROR] The \$UTILS_DIR env var must be defined and " \ | ||
"point to the directory which contains the Common Utilities" | ||
exit 1 | ||
if [[ ${1:-} == "-h" ]]; then | ||
echo "Usage: build [--debug] [-h]" | ||
echo "Builds the project using CMake, with an optional --debug flag to build in Debug mode." | ||
exit 0 | ||
fi | ||
|
||
# shellcheck disable=SC2155 | ||
declare -r COMMON_UTILS="$(realpath $0/..)" | ||
declare -r UTILS="-DCOMMON_UTILS_DIR=${COMMON_UTILS}" | ||
source "${COMMON_UTILS}"/utils.sh | ||
source env.sh | ||
|
||
BUILD=${1:-Debug} | ||
if [[ ${1:-} == "--debug" ]]; then | ||
PRESET=conan-debug | ||
BUILD_TYPE=Debug | ||
else | ||
PRESET=conan-release | ||
BUILD_TYPE=Release | ||
fi | ||
|
||
msg "Build folder in ${BUILDDIR}" | ||
mkdir -p "${BUILDDIR}" | ||
if [[ -f conanfile.txt ]]; then | ||
msg "Installing binary dependencies..." | ||
conan install . -if="${BUILDDIR}" -pr=default --build=missing | ||
conan install . -pr=default \ | ||
--build=missing -s build_type=${BUILD_TYPE} | ||
success "Dependencies installed" | ||
fi | ||
|
||
UTILS="-DCOMMON_UTILS_DIR=${COMMON_UTILS}" | ||
|
||
cd "${BUILDDIR}" | ||
cmake -DCMAKE_CXX_COMPILER="${CLANG}" \ | ||
-DCMAKE_BUILD_TYPE="${BUILD}" \ | ||
"${UTILS}" .. | ||
cmake --build . --target all -- -j 6 | ||
success "Build complete" | ||
msg "Running CMake to configure the build" | ||
cmake --preset ${PRESET} "${UTILS}" | ||
success "CMake configuration complete" | ||
msg "Building the project" | ||
cmake --build --preset ${PRESET} "${UTILS}" --target all -- -j 6 | ||
success "Build complete, targets available in $(realpath ./build/${BUILD_TYPE})" |