From c9c2391d8196f66ba4c7bfa3ace599e400b35700 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 8 Oct 2025 21:55:39 +0100 Subject: [PATCH 1/3] 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/3] 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/3] 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 }}