From c9c2391d8196f66ba4c7bfa3ace599e400b35700 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 8 Oct 2025 21:55:39 +0100 Subject: [PATCH 1/5] Add CMake and Conan presets, update build config Introduces CMakePresets.json and ConanPresets.json for standardized build configuration. Updates Makefile to use CMake presets, modifies .gitignore for IDE files, and refines conanfile.py to support CI option and preset integration. --- .gitignore | 2 + .idea/misc.xml | 12 ++++-- CMakeLists.txt | 1 - CMakePresets.json | 98 +++++++++++++++++++++++++++++++++++++++++++++++ ConanPresets.json | 8 ++++ Makefile | 4 +- conanfile.py | 16 +++++++- 7 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 CMakePresets.json create mode 100644 ConanPresets.json diff --git a/.gitignore b/.gitignore index bebb989d..bf1e94c9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,7 @@ Thumbs.db .idea/dictionaries .idea/shelf .idea/copilot* +.idea/modules.xml +.idea/*.iml .vs/* CMakeUserPresets.json diff --git a/.idea/misc.xml b/.idea/misc.xml index 325891b7..96443667 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,12 @@ + + + + + @@ -9,6 +16,7 @@ - - - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index fd12b1f4..a2268001 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,7 +246,6 @@ message(STATUS "Using Boost ${Boost_VERSION} from Conan") find_package(miniupnpc REQUIRED) find_package(ZLIB REQUIRED) -find_package(ethash REQUIRED) find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS}) include_directories(src "${CMAKE_BINARY_DIR}/version") diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..d288d24e --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,98 @@ +{ + "version": 10, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "$comment": "Lethean presets", + "include": [ + "ConanPresets.json" + + ], + "configurePresets": [ + { + "name": "default", + "displayName": "Default Config", + "description": "Default build using Ninja generator", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/default", + "cacheVariables": { + "TESTNET": "ON" + } + }, + { + "name": "windows-default", + "displayName": "Windows x64 Debug", + "description": "Sets Ninja generator, compilers, x64 architecture, build and install directory, debug build type", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "TESTNET": "ON", + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install/${presetName}" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ "Windows" ] + } + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + } + ], + "testPresets": [ + { + "name": "default", + "configurePreset": "default", + "output": {"outputOnFailure": true}, + "execution": {"noTestsAction": "error", "stopOnFailure": true} + } + ], + "packagePresets": [ + { + "name": "default", + "configurePreset": "default", + "generators": [ + "TGZ", + "ZIP" + ] + } + ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + }, + { + "type": "package", + "name": "default" + } + ] + } + ] +} \ No newline at end of file diff --git a/ConanPresets.json b/ConanPresets.json new file mode 100644 index 00000000..7951a8dd --- /dev/null +++ b/ConanPresets.json @@ -0,0 +1,8 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index 1a33df70..e63cafa3 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ release: docs build @rm -rf $(CURDIR)/build/packages/_CPack_Packages build: configure - cmake --build $(BUILD_FOLDER) --config=$(BUILD_TYPE) --parallel=$(CPU_CORES) + cmake --build --preset conan-release --parallel=$(CPU_CORES) debug: conan-profile-detect @echo "Building profile: debug" @@ -92,7 +92,7 @@ build-deps: conan-profile-detect configure: build-deps @echo "Running Configure: $(BUILD_TYPE) testnet=$(TESTNET)" - cmake -S . -B $(BUILD_FOLDER) -DCMAKE_TOOLCHAIN_FILE=$(BUILD_FOLDER)/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION) + cmake --preset conan-default -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION) docs: configure @echo "Building Documentation" diff --git a/conanfile.py b/conanfile.py index a8f6fbdc..8e998418 100644 --- a/conanfile.py +++ b/conanfile.py @@ -11,11 +11,13 @@ class BlockchainConan(ConanFile): options = { "static": [True, False], - "testnet": [True, False] + "testnet": [True, False], + "ci": [True, False] } default_options = { "static": False, "testnet": False, + "ci": False, "boost/*:without_test": True } @@ -29,7 +31,15 @@ class BlockchainConan(ConanFile): def generate(self): tc = CMakeToolchain(self) - tc.user_presets_path = False + + # When conan-default / conan-release becomes an issue the blow adds OS, ARCH and Compiler to the preset name + # if self.options.__contains__("CI"): + # os_val = str(self.settings.os).lower() + # arch_val = str(self.settings.arch).lower() + # compiler_val = str(self.settings.compiler).lower() + # tc.presets_prefix = f"{os_val}-{arch_val}-{compiler_val}" + + tc.user_presets_path = "ConanPresets.json" tc.variables["STATIC"] = self.options.static tc.variables["TESTNET"] = self.options.testnet # tc.preprocessor_definitions["TESTNET"] = None @@ -40,8 +50,10 @@ class BlockchainConan(ConanFile): deps.generate() def layout(self): + self.folders.generators = os.path.join("build", str(self.settings.build_type).lower(), "generators") self.folders.build = os.path.join("build", str(self.settings.build_type).lower()) + # self.folders.build_folder_vars = ["settings.os", "settings.arch", "settings.compiler", "settings.build_type"] def build(self): cmake = CMake(self) From 414c7379f7a0a4ac2631860ab418388646260727 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 8 Oct 2025 22:00:29 +0100 Subject: [PATCH 2/5] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e63cafa3..adbd145c 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ build-deps: conan-profile-detect configure: build-deps @echo "Running Configure: $(BUILD_TYPE) testnet=$(TESTNET)" - cmake --preset conan-default -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION) + cmake --preset conan-release -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION) docs: configure @echo "Building Documentation" From cea280777edddf96d9b1f42b9a7f8d0ebd35df4b Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 8 Oct 2025 22:14:29 +0100 Subject: [PATCH 3/5] Update _on-pr.yml --- .github/workflows/_on-pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/_on-pr.yml b/.github/workflows/_on-pr.yml index a89bc19e..b8171dbf 100644 --- a/.github/workflows/_on-pr.yml +++ b/.github/workflows/_on-pr.yml @@ -10,6 +10,7 @@ on: - opened - synchronize - reopened + - ready_for_review concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} From 5d9d6f928255626a53bf26ca34452e7e81904b39 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 8 Oct 2025 23:04:54 +0100 Subject: [PATCH 4/5] Refactor build presets and folder layout for Windows Updated Makefile and GitHub workflow to use configurable build and configure presets, improving flexibility for different environments. Adjusted CMakePresets.json to fix preset naming and version, and refactored conanfile.py to set build folders based on compiler type, ensuring correct folder structure for MSVC and other compilers. --- .github/workflows/build-windows-intel.yml | 2 +- CMakePresets.json | 5 ++--- Makefile | 15 +++++---------- conanfile.py | 23 +++++++++++++---------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-windows-intel.yml b/.github/workflows/build-windows-intel.yml index 5038bc65..d2657aeb 100644 --- a/.github/workflows/build-windows-intel.yml +++ b/.github/workflows/build-windows-intel.yml @@ -70,7 +70,7 @@ jobs: - run: pip install mkdocs-material mkdocs-git-revision-date-localized-plugin mkdocs-git-committers-plugin-2 mkdocs-git-authors-plugin "mkdocs-material[imaging]" - name: Compile Release - run: make release CPU_CORES=4 TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }} + run: make release PRESET_CONFIGURE=conan-default CPU_CORES=4 TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }} - name: CLI Artifacts uses: ./.github/actions/upload-artifacts diff --git a/CMakePresets.json b/CMakePresets.json index d288d24e..3f2c576b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,11 +1,10 @@ { - "version": 10, + "version": 8, "cmakeMinimumRequired": { "major": 3, "minor": 23, "patch": 0 }, - "$comment": "Lethean presets", "include": [ "ConanPresets.json" @@ -22,7 +21,7 @@ } }, { - "name": "windows-default", + "name": "windows-defaultss", "displayName": "Windows x64 Debug", "description": "Sets Ninja generator, compilers, x64 architecture, build and install directory, debug build type", "generator": "Ninja", diff --git a/Makefile b/Makefile index adbd145c..babe69da 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,8 @@ STATIC:= 0 BUILD_TYPE ?=Release BUILD_VERSION:=6.0.1 BUILD_FOLDER:=build/release +PRESET_BUILD:=conan-release +PRESET_CONFIGURE:=conan-release # ----------------------------------------------------------------- # Unix‑like systems (Linux, macOS, *BSD, etc.) @@ -77,14 +79,7 @@ release: docs build @rm -rf $(CURDIR)/build/packages/_CPack_Packages build: configure - cmake --build --preset conan-release --parallel=$(CPU_CORES) - -debug: conan-profile-detect - @echo "Building profile: debug" - CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) install . --build=missing -s build_type=Debug - cmake -S . -B $(CURDIR)/build/debug -DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/build/debug/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DTESTNET=$(TESTNET) - cmake --build $(CURDIR)/build/debug --config=Debug --parallel=$(CPU_CORES) - + cmake --build --preset $(PRESET_BUILD) --parallel=$(CPU_CORES) build-deps: conan-profile-detect @echo "Build Dependencies: $(BUILD_TYPE) testnet=$(TESTNET)" @@ -92,7 +87,7 @@ build-deps: conan-profile-detect configure: build-deps @echo "Running Configure: $(BUILD_TYPE) testnet=$(TESTNET)" - cmake --preset conan-release -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION) + cmake --preset $(PRESET_CONFIGURE) -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION) docs: configure @echo "Building Documentation" @@ -165,4 +160,4 @@ clean-build: tags: ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest -.PHONY: all release upload-conan-cache docker-chain-node debug docs docs-dev configure static static-release test test-release test-debug clean tags conan-profile-detect get-conan $(PROFILES) +.PHONY: all release upload-conan-cache docs docs-dev configure static static-release test test-release test-debug clean tags conan-profile-detect get-conan $(PROFILES) diff --git a/conanfile.py b/conanfile.py index 8e998418..ab1a89cb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -32,12 +32,10 @@ class BlockchainConan(ConanFile): def generate(self): tc = CMakeToolchain(self) - # When conan-default / conan-release becomes an issue the blow adds OS, ARCH and Compiler to the preset name - # if self.options.__contains__("CI"): - # os_val = str(self.settings.os).lower() - # arch_val = str(self.settings.arch).lower() - # compiler_val = str(self.settings.compiler).lower() - # tc.presets_prefix = f"{os_val}-{arch_val}-{compiler_val}" + os_val = str(self.settings.os).lower() + # arch_val = str(self.settings.arch).lower() + # compiler_val = str(self.settings.compiler).lower() + # tc.presets_prefix = f"{os_val}" tc.user_presets_path = "ConanPresets.json" tc.variables["STATIC"] = self.options.static @@ -50,10 +48,15 @@ class BlockchainConan(ConanFile): deps.generate() def layout(self): - - self.folders.generators = os.path.join("build", str(self.settings.build_type).lower(), "generators") - self.folders.build = os.path.join("build", str(self.settings.build_type).lower()) - # self.folders.build_folder_vars = ["settings.os", "settings.arch", "settings.compiler", "settings.build_type"] + if self.settings.compiler == "msvc": + # For multi-config, all configurations go into the same "build" folder. + self.folders.build = "build/release" + self.folders.generators = "build/release/generators" + else: + # For single-config, we create a subfolder for each build type. + build_type_str = str(self.settings.build_type).lower() + self.folders.build = os.path.join("build", build_type_str) + self.folders.generators = os.path.join(self.folders.build, "generators") def build(self): cmake = CMake(self) From 20ceda91e58fc794a608168fd33e52ce3181f4e4 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 8 Oct 2025 23:28:09 +0100 Subject: [PATCH 5/5] Update build presets and CPack config for Windows Set PRESET_CONFIGURE to 'conan-default' for Windows builds in Makefile and GitHub workflow. Broaden CPack packaging conditions to include additional build types and comment out WIX generator settings for Windows in CPackConfig.cmake. --- .github/workflows/build-windows-intel.yml | 2 +- Makefile | 9 +++------ cmake/CPackConfig.cmake | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-windows-intel.yml b/.github/workflows/build-windows-intel.yml index d2657aeb..5038bc65 100644 --- a/.github/workflows/build-windows-intel.yml +++ b/.github/workflows/build-windows-intel.yml @@ -70,7 +70,7 @@ jobs: - run: pip install mkdocs-material mkdocs-git-revision-date-localized-plugin mkdocs-git-committers-plugin-2 mkdocs-git-authors-plugin "mkdocs-material[imaging]" - name: Compile Release - run: make release PRESET_CONFIGURE=conan-default CPU_CORES=4 TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }} + run: make release CPU_CORES=4 TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }} - name: CLI Artifacts uses: ./.github/actions/upload-artifacts diff --git a/Makefile b/Makefile index babe69da..6b8ab917 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,6 @@ BUILD_FOLDER:=build/release PRESET_BUILD:=conan-release PRESET_CONFIGURE:=conan-release -# ----------------------------------------------------------------- -# Unix‑like systems (Linux, macOS, *BSD, etc.) -# ----------------------------------------------------------------- UNAME_S := $(shell uname -s 2>/dev/null || echo Unknown) ifeq ($(UNAME_S),Linux) @@ -40,10 +37,10 @@ ifeq ($(filter %BSD,$(UNAME_S)),%BSD) CPU_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null || echo 1) endif -# ----------------------------------------------------------------- -# Windows (detected by the built‑in $(OS) variable set by GNU make) -# ----------------------------------------------------------------- ifeq ($(OS),Windows_NT) + +PRESET_CONFIGURE:=conan-default + # Prefer the environment variable that Windows sets for us. # It works in both cmd.exe and PowerShell. CPU_CORES := $(NUMBER_OF_PROCESSORS) diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake index c120a637..047fd324 100644 --- a/cmake/CPackConfig.cmake +++ b/cmake/CPackConfig.cmake @@ -1,6 +1,6 @@ -if(CMAKE_BUILD_TYPE STREQUAL "Release") +if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" OR CMAKE_BUILD_TYPE STREQUAL "") set(CPACK_PACKAGE_NAME "${package_name}") set(CPACK_PACKAGE_VENDOR "${package_vendor}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${package_description}") @@ -26,8 +26,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release") # message(STATUS "Registered CPACK_GENERATOR: productbuild") endif () elseif(WIN32) - # set(CPACK_GENERATOR "WIX") - # message(STATUS "Registered CPACK_GENERATOR: WIX") +# set(CPACK_GENERATOR "WIX") +# message(STATUS "Registered CPACK_GENERATOR: WIX") # set(CPACK_WIX_PRODUCT_ICON "${CMAKE_SOURCE_DIR}/resources/windows_icon.ico") # set(CPACK_WIX_LICENSE_RTF "${CMAKE_SOURCE_DIR}/LICENSE.rtf") # set(CPACK_WIX_UPGRADE_GUID "D3F5A9C1-4B2E-4F5A-9C71-123456789ABC") # change once per major version