New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Multiple parallel profiles support in cmake_layout()
#11189
Comments
This works (assuming CMake 3.23, and I am using Windows VS, but the case is identical for other compilers): conan new hello/0.1 -m=cmake_lib
conan install . -s compiler.version=15 -of=build/vs15 -if=build/vs15
# this generates a CMakeUserPresets.json besides the CMakeLists.txt
conan install . -s compiler.version=15 -of=build/vs15 -if=build/vs15 -s build_type=Debug
conan install . -s compiler.version=17 -of=build/vs17 -if=build/vs17
conan install . -s compiler.version=17 -of=build/vs17 -if=build/vs17 -s build_type=Debug
cmake --preset=default # configures vs15
cmake --build --preset=Release # builds vs15, Release in build/vs15/build/Release
cmake --build --preset=Debug # builds vs15, Debug in build/vs15/build/Debug
# Replace "vs15" => "vs17" in the ``CMakeUserPresets.json`` ``include()``
cmake --preset=default # configures vs17
cmake --build --preset=Release # builds vs17, Release in build/vs17/build/Release
cmake --build --preset=Debug # builds vs17, Debug in build/vs17/build/Debug I would say the user experience is fantastic so far, you can easily test for multiple compilers and configurations. Regarding your comments:
So in summary, I think the workflow and layout that you want to achieve is not only possible, but also natural and smooth. There could be some further improvements, like trying to do some composition over It might also be possible to add a |
Recap: My goal is to generate all the files for all the configurations once with Conan and after that open the project in the IDE and use this IDE to switch between different configurations and build all of the targets.
Yes, my fault.
Well, this is not that easy. It is not only a matter of replacing or stacking all the includes in the
Yes, I admit this is probably the main problem here. I suggested using a profile file name above but it is far from being a perfect solution. Maybe there should be a dedicated command line parameter (i.e.
|
👍🏼
Well, we cannot couple a
We will do a POC with a I admit that managing all these different configurations with your IDE just selecting the Preset would be pretty cool. Let's see if we can do it in an easy and "sane" way for the conan Client. Thanks Mateusz |
Thanks @lasote!v The parameter I proposed does not have to be named |
I just tried the feature in 1.49. It seems there is some issue for a multi-config generator. If I set Also, there is one thing that could be improved in my opinion. Is it possible to put "Release/Debug" part at the end of the list rather in the beginning of the preset and directories names? Right now I get the following file tree:
It is quite hard to reason about and maintain. I think that the following file tree has more sense:
The above does not use |
Also, |
Hi!
It should be working, I'll take a look. About the folders, as the generators (CMakeDeps, CMakeToolchain) are "multi-config", we needed to extract the folder from the build because it is shared between debug and release. So we also decided to have them in the same place for single and multi configuration cmake generators. Thanks! I will let you know about the bug your reported as soon as I reproduce. |
Hi again Mateusz! I'm not able to reproduce the issue. Both Release and Debug configurations are generated correctly. Would it be possible to get an example with the steps to reproduce?
About that, yes, the good news is that that file and friends are gone in Conan 2.0. In Conan 1.X they don't respond to the layout. |
Hi @lasote! I am so sorry for the confusion. I really do not know what happened. Today the same command lines for the same projects in the same IDE (I just put my laptop to sleep overnight) do not reproduce the problem. Strange... and sorry. Still, the directory layout could be optimized a bit ;-)
|
No problem! if you reproduce again let me know.
yes! I tried Clion and the "bin dir" is set to the one you put in the Preset so I would say, we don't have further reasons to keep that layout so I will open a PR to change it and discuss it with the team. I also like more this one:
|
Is it possible to prevent repeating the same preset in ...,
"buildPresets": [
{
"name": "Release-gcc-11",
"configurePreset": "default-gcc-11",
"configuration": "Release"
},
{
"name": "Release-gcc-11",
"configurePreset": "default-gcc-11",
"configuration": "Release"
}
],
... |
Until now I used a simple workflow for each of the compilers using
Ninja Multi-Config
as the default CMake generator:I also set the following in VSCode which makes it work like a charm (with just 3 first steps from the above):
cmake.buildDirectory
to${workspaceFolder}/build/${buildKitVendor}-${buildKitVersionMajor}
cmake.configureArgs
to--toolchain conan_toolchain.cmake
However, the introduction of
cmake_layout()
as a recommended practice in modern Conan recipes will make the above a lot harder if not impossible so I am looking for the best alternative.Right now while using
cmake_layout()
, no matter what the profile file or a current directory is, all the artifacts land out in:<project_root>/build/generators
<project_root>/build
(muti-config) or<project_root>/cmake-build-<build_type>
(single-config)The above scenario accounts only for the differences in the
build_type
between several Conan runs. However, there are more variables there: compiler, compiler version, C++ version used, the standard library used, ... If we run Conan for such configurations the artifacts will collide as they will land out in the same subdirectories. We can use-of <dir>
(i.e.-of build/GCC-11
) to handle the differences manually but:CMakeUserPresets.json
will not land in the correct place to be found by CMake invocations so one must copy it (and override) to the project source directory before every CMake build.CMakeUserPresets.json
that will allow opening such a tree of configurations in the IDE. Even if there was one, all the preset names would collide as they do not use any configuration-specific prefix today.build/GCC-11/build/Release
andbuild/GCC-11/build/generators
I strongly believe that is a good practice to check the source code on several different compilers before committing changes to the repo. Also such configurations are useful to easily reproduce issues raised by the customers or CI. It would be good if Conan could still facilitate such scenarios with the new
cmake_layout()
in the recipes.Unfortunately, I do not have a production-ready solution at hand right now but I hope that we might find one together. The simplest one would be to use a profile name as a prefix/discriminator if it is different from the
default
. That, however, does not account for settings changes provided from the command line (likeconan install . -pr gcc11 -s compiler .version=10
) but I do not believe this is a common practice. Probably the most common isconan install . -pr gcc11 -s build_type=Debug
which would be fine as those already land-out under the same file tree.The text was updated successfully, but these errors were encountered: