forked from lthn/blockchain
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.
This commit is contained in:
parent
106b3431db
commit
c9c2391d81
7 changed files with 132 additions and 9 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -10,5 +10,7 @@ Thumbs.db
|
|||
.idea/dictionaries
|
||||
.idea/shelf
|
||||
.idea/copilot*
|
||||
.idea/modules.xml
|
||||
.idea/*.iml
|
||||
.vs/*
|
||||
CMakeUserPresets.json
|
||||
|
|
|
|||
12
.idea/misc.xml
generated
12
.idea/misc.xml
generated
|
|
@ -1,5 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.13 virtualenv at $PROJECT_DIR$.venv" />
|
||||
</component>
|
||||
<component name="CMakePythonSetting">
|
||||
<option name="pythonIntegrationState" value="YES" />
|
||||
</component>
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="CidrRootsConfiguration">
|
||||
<excludeRoots>
|
||||
<file path="$PROJECT_DIR$/build" />
|
||||
|
|
@ -9,6 +16,7 @@
|
|||
<component name="MakefileSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<MakefileProjectSettings>
|
||||
<option name="buildOptions" value="--jobs=30" />
|
||||
<option name="buildTarget" value="build" />
|
||||
<option name="cleanTarget" value="clean-build" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
|
|
@ -23,8 +31,4 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="CMakePythonSetting">
|
||||
<option name="pythonIntegrationState" value="YES" />
|
||||
</component>
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
98
CMakePresets.json
Normal file
98
CMakePresets.json
Normal file
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
8
ConanPresets.json
Normal file
8
ConanPresets.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
]
|
||||
}
|
||||
4
Makefile
4
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"
|
||||
|
|
|
|||
16
conanfile.py
16
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue