From e8e211878472cb95eb45310620a47c29279be701 Mon Sep 17 00:00:00 2001 From: Snider Date: Sat, 27 Sep 2025 12:40:54 +0100 Subject: [PATCH] Make build type configurable in Makefile Added BUILD_TYPE variable to allow specifying build type (e.g., Release, Debug) for all build targets. Updated Conan and CMake commands to use the configurable build type. Cleaned up apple-clang profile files by removing unnecessary user_presets configuration. --- Makefile | 27 ++++++++++++++------------- cmake/profiles/apple-clang-armv8 | 2 +- cmake/profiles/apple-clang-x86_64 | 3 +-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index d8651f48..d3cb096c 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ # Default to “unknown” – will be overwritten below. CPU_CORES := 1 TESTNET ?= 0 +BUILD_TYPE ?=Release # ----------------------------------------------------------------- # Unix‑like systems (Linux, macOS, *BSD, etc.) @@ -73,15 +74,15 @@ CONAN_CPU_COUNT=$(CPU_CORES) PROFILES := $(patsubst cmake/profiles/%,%,$(wildcard cmake/profiles/*)) SORTED_PROFILES := $(sort $(PROFILES)) CONAN_CACHE := $(CURDIR)/build/sdk -DEFAULT_CONAN_PROFILE := $(CONAN_CACHE)/cmake/profiles/default +DEFAULT_CONAN_PROFILE := $(CONAN_CACHE)/profiles/default all: help release: conan-profile-detect @echo "Building profile: release" - CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release --build=missing -s build_type=Release - cmake -S . -B build/release -DCMAKE_TOOLCHAIN_FILE=build/release/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DTESTNET=$(TESTNET) - cmake --build build/release --config=Release --parallel=$(CPU_CORES) + CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release --build=missing -s build_type=$(BUILD_TYPE) + cmake -S . -B build/release -DCMAKE_TOOLCHAIN_FILE=build/release/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DTESTNET=$(TESTNET) + cmake --build build/release --config=$(BUILD_TYPE) --parallel=$(CPU_CORES) debug: conan-profile-detect @echo "Building profile: debug" @@ -92,8 +93,8 @@ debug: conan-profile-detect static: static-release static-release: conan-profile-detect @echo "Building profile: release-static" - CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release-static --build=missing - cmake -S . -B build/release-static -DCMAKE_TOOLCHAIN_FILE=build/release-static/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -D STATIC=ON -DTESTNET=$(TESTNET) + CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release-static --build=missing -s build_type=$(BUILD_TYPE) + cmake -S . -B build/release-static -DCMAKE_TOOLCHAIN_FILE=build/release-static/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -D STATIC=ON -DTESTNET=$(TESTNET) cmake --build build/release-static --config=Release --parallel=$(CPU_CORES) conan-profile-detect: @@ -106,9 +107,9 @@ conan-profile-detect: # Rule for each profile $(PROFILES): conan-profile-detect @echo "Building profile: $@" - CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/$@ --profile=cmake/profiles/$@ --build=missing - cmake -S . -B build/$@ -DCMAKE_TOOLCHAIN_FILE=build/$@/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DTESTNET=$(TESTNET) - cmake --build build/$@ --config=Release --parallel=$(CPU_CORES) + CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/$@ -pr:b=$(DEFAULT_CONAN_PROFILE) -pr:h=cmake/profiles/$@ --build=missing -s build_type=$(BUILD_TYPE) + cmake -S . -B build/$@ -DCMAKE_TOOLCHAIN_FILE=build/$@/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DTESTNET=$(TESTNET) + cmake --build build/$@ --config=$(BUILD_TYPE) --parallel=$(CPU_CORES) help: @echo "Available targets:" @@ -131,22 +132,22 @@ help: test: test-release test-release: @echo "Building profile: test-release" - CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/test-release --build=missing + CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/test-release --build=missing -s build_type=$(BUILD_TYPE) cmake -S . -B build/test-release -DCMAKE_TOOLCHAIN_FILE=build/test-release/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -D BUILD_TESTS=ON cmake --build build/test-release --config=Release --parallel=$(CPU_CORES) $(MAKE) test test-debug: @echo "Building profile: test-debug" - CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/test-debug --build=missing + CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/test-debug --build=missing -s build_type=$(BUILD_TYPE) cmake -S . -B build/test-debug -DCMAKE_TOOLCHAIN_FILE=build/test-debug/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -D BUILD_TESTS=ON cmake --build build/test-debug --config=Debug --parallel=$(CPU_CORES) $(MAKE) test configure: @echo "Running Config: release" - CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release --build=missing -s build_type=Release - cmake -S . -B build/release -DCMAKE_TOOLCHAIN_FILE=build/release/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release + CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release --build=missing -s build_type=$(BUILD_TYPE) + cmake -S . -B build/release -DCMAKE_TOOLCHAIN_FILE=build/release/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) docs: configure @echo "Building Documentation" diff --git a/cmake/profiles/apple-clang-armv8 b/cmake/profiles/apple-clang-armv8 index 72a0c026..0f36faa5 100644 --- a/cmake/profiles/apple-clang-armv8 +++ b/cmake/profiles/apple-clang-armv8 @@ -6,4 +6,4 @@ compiler.version=13 compiler.libcxx=libc++ [conf] -tools.cmake.cmaketoolchain:user_presets=False + diff --git a/cmake/profiles/apple-clang-x86_64 b/cmake/profiles/apple-clang-x86_64 index adda230c..9af72645 100644 --- a/cmake/profiles/apple-clang-x86_64 +++ b/cmake/profiles/apple-clang-x86_64 @@ -5,5 +5,4 @@ compiler=apple-clang compiler.version=13 compiler.libcxx=libc++ -[conf] -tools.cmake.cmaketoolchain:user_presets=False \ No newline at end of file +[conf] \ No newline at end of file