[question] Check example examples2/examples/tools/cmake/cmake_toolchain/extend_own_cmake_presets
What is your question?
Hi!
In example https://github.com/conan-io/examples2/tree/main/examples/tools/cmake/cmake_toolchain/extend_own_cmake_presets using ConanPreset.json. Can you check the functionality?
What's the problem: after calling conan install .I'm checkingcmake --list-presets and I get the error Invalid preset: "conan-debug"
As I found out, the problem is in the ConanPresets file.json and a stub for the buildPresets/conan-debug field.
"buildPresets": [
{
"name": "conan-debug"
}
],
If I add a configurePreset
"buildPresets": [
{
"name": "conan-debug",
"configurePreset": "conan-debug"
}
]
then `cmake --list-presets' works:
$ cmake --list-presets
Available configure presets:
"default" - multi config
"release" - release single config
"debug" - debug single config
"conan-default"
"conan-debug"
"conan-release" - 'conan-release' config
Macos Sequoia 15.7 cmake version 3.28.3 conan version 2.17.0
I also checked in the docker container CentOS Linux 8 cmake version 3.31.9 Conan version 2.21.0
Have you read the CONTRIBUTING guide?
- [x] I've read the CONTRIBUTING guide
Hi @kostprof21
Thanks for the feedback.
What's the problem: after calling conan install .I'm checkingcmake --list-presets and I get the error Invalid preset: "conan-debug"
When using a multi-config generator with this approach, it is necessary to install both the Debug and Release configurations, as described in https://docs.conan.io/2/examples/tools/cmake/cmake_toolchain/extend_own_cmake_presets.html, it is necessary to do:
conan install .
conan install . -s build_type=Debug
That way both Release and Debug expected information will be filled and the presets will work.
Can you please try that?
I'm usnig generator "Unix Makefiles" or "Ninja".
The problem is the generation of stubs in ConanPreset.json for buildPresets. It looks like this is a cmake problem, as I did not find the mandatory availability of additional field configurePreset inbuildPresets/. But since there is a problem (maybe only I have) it is worth correcting if it manifests itself in others. For this reason, I ask you to try to reproduce it.
Hi @memsharded,
Any news?
Hi @kostprof21
I am afraid that I a missing details and information to reproduce. If you are using the Ninja generator, then the command line must be something like:
conan install .... -c tools.cmake.cmaketoolchaing:generator=Ninja
because if not, Conan will use by default the default Visual Studio generator that is multi-config and requires both Debug and Release configurations and dependencies to be installed. This is why I was suggesting above:
conan install .
conan install . -s build_type=Debug
which is the documented way, because in the docs that you are linking Ninja is not being used, so you are doing some different steps than the docs, but those details were missing in the report above.
@memsharded okay, let's start in order, I hope I'm not missing anything. My system macOS Sequoia 15.7.1, default profile
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=16
os=Macos
- In
examples/tools/cmake/cmake_toolchain/extend_own_cmake_presetscalling
conan install . --build=missing
In build/Release/generators/CMakePresets.json in fields configurePresets for conan-release using "generator": "Unix Makefiles".
- Calling
cmake --list-presets
I get error:
CMake Error: Could not read presets from examples/tools/cmake/cmake_toolchain/extend_own_cmake_presets:
Invalid preset: "conan-debug"
- Open the generated
examples/tools/cmake/cmake_toolchain/extend_own_cmake_presets/ConanPresets.jsonand add"configurePreset": "conan-debug"in"buildPresets"for "conan-debug" like this
"buildPresets": [
{
"name": "conan-debug",
"configurePreset": "conan-debug"
}
]
- Check
cmake --list-presets. It's OK:
> cmake --list-presets
Available configure presets:
"default" - multi config
"release" - release single config
"debug" - debug single config
"conan-default"
"conan-debug"
"conan-release" - 'conan-release' config
The same behavior if I use Ninja