From b02ef148aaf7aabed9f9a22ac88ca22d995e985e Mon Sep 17 00:00:00 2001 From: "l.feng" <43399351+msclock@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:30:11 +0800 Subject: [PATCH] perf: simplify cmake presets Signed-off-by: l.feng <43399351+msclock@users.noreply.github.com> --- template/cmake/presets/base.json | 80 +++++++++++--------- template/cmake/presets/default.json | 10 +++ template/cmake/presets/generators/ninja.json | 38 ---------- 3 files changed, 53 insertions(+), 75 deletions(-) diff --git a/template/cmake/presets/base.json b/template/cmake/presets/base.json index f1b7667..f41a688 100644 --- a/template/cmake/presets/base.json +++ b/template/cmake/presets/base.json @@ -5,63 +5,68 @@ "toolchains/vcpkg.json" ], "configurePresets": [ + { + "name": "base-common", + "hidden":true, + "binaryDir":"${sourceDir}/out/build/${presetName}", + "installDir":"${sourceDir}/out/install/${presetName}", + "cacheVariables":{ + "CMAKE_COMPILE_WARNING_AS_ERROR":false, + "CMAKE_EXPORT_COMPILE_COMMANDS":true, + "CMAKE_VERBOSE_MAKEFILE":"FALSE" + } + }, { "name": "base", "hidden": true, "inherits": [ + "base-common", "ninja", "vcpkg" ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_VERBOSE_MAKEFILE": "FALSE" + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "base-config", "hidden": true, "inherits": [ + "base-common", "ninja-config", "vcpkg" - ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_VERBOSE_MAKEFILE": "FALSE" - } + ] } ], "buildPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base" }, + { + "name": "base-config-debug", + "hidden": true, + "configurePreset": "base-config", + "configuration": "Debug" + }, { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "RelWithDebInfo" }, { - "name": "base-config-debug", + "name": "base-config-release", "hidden": true, - "inherits": "ninja-config-debug", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "Release" } ], "testPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base", "output": { "outputOnFailure": true @@ -74,28 +79,29 @@ { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "RelWithDebInfo" }, { "name": "base-config-debug", "hidden": true, - "inherits": "ninja-config-debug", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "Debug" + }, + { + "name": "base-config-release", + "hidden": true, + "inherits": [ + "base" + ], + "configurePreset": "base-config", + "configuration": "Release" } ] } diff --git a/template/cmake/presets/default.json b/template/cmake/presets/default.json index 7423711..0db1eb6 100644 --- a/template/cmake/presets/default.json +++ b/template/cmake/presets/default.json @@ -32,6 +32,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ], "testPresets": [ @@ -49,6 +54,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ] } diff --git a/template/cmake/presets/generators/ninja.json b/template/cmake/presets/generators/ninja.json index 424407d..2280f4e 100644 --- a/template/cmake/presets/generators/ninja.json +++ b/template/cmake/presets/generators/ninja.json @@ -11,43 +11,5 @@ "hidden": true, "generator": "Ninja Multi-Config" } - ], - "buildPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } - ], - "testPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } ] }