-
-
Notifications
You must be signed in to change notification settings - Fork 37
cmake presets are not usable (at leased on OSX) #31
Comments
Re: @Jason5480 |
something like this is missing: "buildPresets": [
{
"name": "test",
"configurePreset": "test"
},
{
"name": "ninja-multi",
"configurePreset": "ninja-multi"
}
],
"testPresets": [
{
"name": "test",
"configurePreset": "test",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": true}
},
{
"name": "ninja-multi",
"configurePreset": "ninja-multi",
"inherits": "test"
}
] |
@ClausKlein the testPreset corresponding to the 'unixlike-gcc-release' configurePreset is the 'test-unixlike-gcc-release' so this is the name that should be passed to the ctest command. |
If you use a multi config generator, then buildPresets are needed. But with a simple Ninja generator you do not have to pass a preset to the build stage. I have a PR that does that for "Ninja Multi-Config" generator but is still pending #19. @ClausKlein please if you have some time check if this work on OSX since I cannot check that. |
@Jason5480 I can't use it to configure the build! bash-3.2$ git status
On branch feature/ninja-multi-presets-support
Your branch is up to date with 'Nikolas/feature/ninja-multi-presets-support'.
nothing to commit, working tree clean
bash-3.2$ cmake -S . --list-presets=all
Available build presets:
"build-windows-msvc-debug" - Debug
"build-windows-msvc-release" - Release
"build-linux-gcc-debug" - Debug
"build-linux-gcc-release" - Release
"build-linux-clang-debug" - Debug
"build-linux-clang-release" - Release
Available test presets:
"test-windows-msvc-debug" - Debug
"test-windows-msvc-release" - Release
"test-linux-gcc-debug" - Debug
"test-linux-gcc-release" - Release
"test-linux-clang-debug" - Debug
"test-linux-clang-release" - Release
bash-3.2$ |
with a little love, is seems better: bash-3.2$ cmake -S . --list-presets=all
Available configure presets:
"linux-gcc" - gcc
"linux-clang" - clang
Available build presets:
"build-windows-msvc-debug" - Debug
"build-windows-msvc-release" - Release
"build-linux-gcc-debug" - Debug
"build-linux-gcc-release" - Release
"build-linux-clang-debug" - Debug
"build-linux-clang-release" - Release
Available test presets:
"test-windows-msvc-debug" - Debug
"test-windows-msvc-release" - Release
"test-linux-gcc-debug" - Debug
"test-linux-gcc-release" - Release
"test-linux-clang-debug" - Debug
"test-linux-clang-release" - Release
bash-3.2$ git diff diff --git a/CMakePresets.json b/CMakePresets.json
index a33a880..9d237b3 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -35,17 +35,7 @@
"name": "config-linux-common",
"description": "Linux settings for gcc and clang toolchains",
"hidden": true,
- "inherits": "config-common",
- "condition": {
- "type": "equals",
- "lhs": "${hostSystemName}",
- "rhs": "Linux"
- },
- "vendor": {
- "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
- "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
- }
- }
+ "inherits": "config-common"
},
{
"name": "windows-msvc",
@@ -231,4 +221,4 @@
"configurePreset": "linux-clang"
}
]
-}
\ No newline at end of file
+}
bash-3.2$ |
What is the concept behind your presets? bash-3.2$ cmake -S . --preset=linux-common
CMake Error: No such preset in /Users/clausklein/Workspace/cpp/cpp_boilerplate_project: "linux-common"
Available configure presets:
"linux-gcc" - gcc
"linux-clang" - clang
bash-3.2$ cmake -S . --preset=linux-gcc
Preset CMake variables:
CMAKE_BUILD_TYPE="Debug"
CMAKE_CXX_COMPILER="g++"
CMAKE_C_COMPILER="gcc"
######################################################
Warning: in-source builds are disabled
Please create a separate build directory and run cmake from there
######################################################
CMake Error at _deps/_project_options-src/src/PreventInSourceBuilds.cmake:15 (message):
Quitting configuration
Call Stack (most recent call first):
_deps/_project_options-src/src/PreventInSourceBuilds.cmake:19 (assure_out_of_source_builds)
_deps/_project_options-src/src/Index.cmake:7 (include)
_deps/_project_options-src/Index.cmake:1 (include)
CMakeLists.txt:29 (include)
-- Configuring incomplete, errors occurred!
bash-3.2$ pwd
/Users/clausklein/Workspace/cpp/cpp_boilerplate_project
bash-3.2$ |
I have this on my ModernCmakeStarter: bash-3.2$ cmake -S . --list-presets=all
Available configure presets:
"test" - Test Config
"ninja-multi" - Ninja Multi-Config
Available build presets:
"test"
"ninja-multi"
Available test presets:
"test"
"ninja-multi"
bash-3.2$
|
If I add this line: |
@Jason5480 Only if have the same names for associated presets, it works: bash-3.2$ cmake -S . --list-presets=all
Available configure presets:
"linux-gcc" - gcc
"linux-clang" - clang
Available build presets:
"build-windows-msvc-debug" - Debug
"build-windows-msvc-release" - Release
"linux-gcc" - Debug
"linux-clang" - Debug
Available test presets:
"test-windows-msvc-debug" - Debug
"test-windows-msvc-release" - Release
"linux-gcc" - Debug
"linux-clang" - Debug
bash-3.2$ |
I was talking about the |
That is strange... your IDE should let you choose between different configure, build and test Presets. At least this is what VSCode and Visual Studio do. What IDE do you use? or you run cmake commands directly? |
@Jason5480 OK, tomorrow I will hav a look P.S. I working on |
|
I tried those commands in `cmake --preset=unixlike-gcc-release cmake --build --preset=build-unixlike-gcc-release ctest --build --preset=test-unixlike-gcc-release` The equivalent for this repository should be cmake --build ctest --build --preset=test-unixlike-gcc-release` However, I did not test the later case. |
@Jason5480 I can't understand your concept! bash-3.2$ git diff
diff --git a/CMakePresets.json b/CMakePresets.json
index 631c366..8817376 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -40,6 +40,7 @@
"description": "Unix-like OS settings for gcc and clang toolchains",
"hidden": true,
"inherits": "config-common",
+ "binaryDir": "${sourceDir}/build",
"condition": {
"type": "inList",
"string": "${hostSystemName}",
@@ -47,11 +48,6 @@
"Linux",
"Darwin"
]
- },
- "vendor": {
- "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
- "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
- }
}
},
{
@@ -278,4 +274,4 @@
"configurePreset": "unixlike-clang"
}
]
-}
\ No newline at end of file
+}
bash-3.2$ cmake -S . --list-presets=all
CMake Error: Could not read presets from /Users/clausklein/Workspace/cpp/cpp_boilerplate_project: Invalid "configurePreset" field
bash-3.2$ pwd
/Users/clausklein/Workspace/cpp/cpp_boilerplate_project
bash-3.2$ git branch
develop
feature/modernize-cmake-project-options
feature/ninja-multi-presets-support
* feature/presets-enchancements
main
bash-3.2$ P.S. Keep it as simple as possible! |
I would expect to not see any preset which is not usable on my machine. P.S: don't forget see too https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-2.html |
@Jason5480 keep it simple helps! bash-3.2$ cmake -S . --debug-output --list-presets=all
Running with debug output on.
Available configure presets:
"unixlike-gcc" - gcc
"unixlike-clang" - clang
Available build presets:
"windows-msvc-developer-debug" - Debug
"windows-msvc-developer-release" - Release
"windows-msvc-user-debug" - Debug
"windows-msvc-user-release" - Release
"windows-msvc-debug" - Debug
"windows-msvc-release" - Release
"gcc-debug" - Debug
"gcc-release" - Release
"clang-debug" - Debug
"clang-release" - Release
Available test presets:
"windows-msvc-developer-debug" - Debug
"windows-msvc-developer-release" - Release
"windows-msvc-user-debug" - Debug
"windows-msvc-user-release" - Release
"windows-msvc-debug" - Debug
"windows-msvc-release" - Release
"windows-clang-debug" - Debug
"windows-clang-release" - Release
"gcc-debug" - Debug
"gcc-release" - Release
"clang-debug" - Debug
"clang-release" - Release
bash-3.2$ |
Thanks, I will remove the unnecessary 'build-' and 'test-' prefixes in my PR!
When the project is configured build for release it like this
or for debug like this
Then run the tests to make sure all went as expected.
or
Let me know how that went |
Hmm there is a condition that should prevent that. Well, it does try to pass the
The possible combinations between 3 OSes and 4 compiler toolchains are already too many to support. Keep in mind that with every new toolchain added in the presets we should also add a CI job that verifies the correctness @ddalcino is it possible to support the aforementioned configurations in the CI soon?
I will check that thanks |
…e life easier as @KlausKlein suggested here cpp-best-practices#31 (comment)
@ClausKlein I found that the condition ${hostSystemName} was not applied in the build and test presets... I will also add this in my PR. So, you were right about that. It is extremely helpful feedback! Thank you |
@lefticus @Jason5480 I had investigated about half a day to fix this presets, prepared a |
Please note too this |
I took into account your requirement not to see the windows presents on unixlike system which is fair and logical. To prevent duplication in every condition I created two separate "windows" and "unixlike" presets where I put the conditions. Your condition for unixlike is opt-out where the existing condition was opt-in. |
…e life easier as @KlausKlein suggested here cpp-best-practices#31 (comment)
…so to prevent clutter (+1 squashed commits) Squashed commits: [7f3630d] Keep it simple remove unecessary 'build-` and 'test-` prefixes to make life easier as @KlausKlein suggested here cpp-best-practices#31 (comment)
…so to prevent clutter (+1 squashed commits) Squashed commits: [7f3630d] Keep it simple remove unecessary 'build-` and 'test-` prefixes to make life easier as @KlausKlein suggested here cpp-best-practices#31 (comment)
The text was updated successfully, but these errors were encountered: