diff --git a/.idea/cmake.xml b/.idea/cmake.xml deleted file mode 100644 index b5778816..00000000 --- a/.idea/cmake.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json index 3f2c576b..07cb3684 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,64 +7,63 @@ }, "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-defaultss", - "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" + "name": "testnet", + "binaryDir": "${sourceDir}/build/release", + "environment": { + "CONAN_HOME": "${sourceDir}/build/sdk" }, "cacheVariables": { "TESTNET": "ON", - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install/${presetName}" + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"cmake/conan_provider.cmake" + } + }, + { + "name": "mainnet", + "binaryDir": "${sourceDir}/build/release", + "environment": { + "CONAN_HOME": "${sourceDir}/build/sdk" }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "hostOS": [ "Windows" ] - } - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" + "cacheVariables": { + "TESTNET": "OFF", + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"cmake/conan_provider.cmake" } } ], "buildPresets": [ { - "name": "default", - "configurePreset": "default" + "name": "testnet", + "configurePreset": "testnet" + }, + { + "name": "mainnet", + "configurePreset": "mainnet" } ], "testPresets": [ { - "name": "default", - "configurePreset": "default", + "name": "mainnet", + "configurePreset": "mainnet", "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": true} } ], "packagePresets": [ { - "name": "default", - "configurePreset": "default", + "name": "mainnet", + "configurePreset": "mainnet", + "generators": [ + "TGZ", + "ZIP" + ] + }, + { + "name": "testnet", + "configurePreset": "testnet", "generators": [ "TGZ", "ZIP" @@ -73,23 +72,36 @@ ], "workflowPresets": [ { - "name": "default", + "name": "testnet", "steps": [ { "type": "configure", - "name": "default" + "name": "testnet" }, { "type": "build", - "name": "default" - }, - { - "type": "test", - "name": "default" + "name": "testnet" }, { "type": "package", - "name": "default" + "name": "testnet" + } + ] + }, + { + "name": "mainnet", + "steps": [ + { + "type": "configure", + "name": "mainnet" + }, + { + "type": "build", + "name": "mainnet" + }, + { + "type": "package", + "name": "mainnet" } ] } diff --git a/Makefile b/Makefile index 6b8ab917..60068533 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,12 @@ CC_DOCKER_FILE?=utils/docker/images/lthn-chain/Dockerfile all: help +testnet: + cmake --workflow testnet + +mainnet: + cmake --workflow mainnet + release: docs build (cd $(BUILD_FOLDER) && cpack) @rm -rf $(CURDIR)/build/packages/_CPack_Packages @@ -90,18 +96,6 @@ docs: configure @echo "Building Documentation" cmake --build build/release --target=docs --config=Release --parallel=$(CPU_CORES) -# allowing this target to error quietly saves cross brwoser file detection -get-conan: - cmake -P cmake/GetConan.cmake - (CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) remote add conan_build $(CONAN_URL) && \ - CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) remote login conan_build $(CONAN_USER) -p $(CONAN_PASSWORD)) || true - -upload-conan-cache: - CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) upload "*" -r=conan_build --confirm - -conan-profile-detect: get-conan - cmake -P cmake/ConanProfileSetup.cmake - # Rule for each profile $(PROFILES): conan-profile-detect @echo "Building profile: $@" @@ -144,6 +138,18 @@ test-debug: cmake --build build/test-debug --config=Debug --parallel=$(CPU_CORES) $(MAKE) test +# allowing this target to error quietly saves cross brwoser file detection +conan-get: + cmake -P cmake/GetConan.cmake + (CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) remote add conan_build $(CONAN_URL) && \ + CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) remote login conan_build $(CONAN_USER) -p $(CONAN_PASSWORD)) || true + +conan-upload: + CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) upload "*" -r=conan_build --confirm + +conan-profile-detect: conan-get + cmake -P cmake/ConanProfileSetup.cmake + docs-dev: configure @echo "Building Documentation" cmake --build build/release --target=serve_docs --config=Release diff --git a/cmake/CleanBuild.cmake b/cmake/CleanBuild.cmake index 0a1146db..e9f3ab79 100644 --- a/cmake/CleanBuild.cmake +++ b/cmake/CleanBuild.cmake @@ -55,4 +55,22 @@ function(selective_clean_build_dir) endif() endfunction() +function(reset_conan_presets) + set(CONAN_PRESETS_FILE "${CMAKE_SOURCE_DIR}/ConanPresets.json") + + set(NEW_CONTENT [[{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + + ] +}]]) + message(STATUS "Resetting ${CONAN_PRESETS_FILE} to a clean state.") + file(WRITE "${CONAN_PRESETS_FILE}" "${NEW_CONTENT}") + message(STATUS "${CONAN_PRESETS_FILE} has been successfully reset.") +endfunction() + selective_clean_build_dir() +reset_conan_presets() diff --git a/cmake/conan_provider.cmake b/cmake/conan_provider.cmake index 1a6d9ec6..c524fb7f 100644 --- a/cmake/conan_provider.cmake +++ b/cmake/conan_provider.cmake @@ -572,7 +572,7 @@ macro(conan_provide_dependency method package_name) endif () if(NOT EXISTS ${CONAN_COMMAND}) message(STATUS "CMake-Conan: Local conan not found, attempting to download it.") - execute_process(COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/GetConan.cmake" + execute_process(COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/GetConan.cmake" RESULT_VARIABLE result WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") if(NOT result EQUAL 0)