[feature] Multiple parallel profiles support in `cmake_layout()`
See original GitHub issueUntil now I used a simple workflow for each of the compilers using Ninja Multi-Config
as the default CMake generator:
mkdir -p build/GCC-11 && cd build/GCC-11
conan install ../.. -pr gcc11
conan install ../.. -pr gcc11 -s build_type=Debug
cmake ../.. --toolchain conan_toolchain.cmake
cmake --build . --config Release
cmake --build . --config Debug
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
- either
<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.- There will be no aggregated
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. - We might end up with some strange paths to work with like
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 (like conan install . -pr gcc11 -s compiler .version=10
) but I do not believe this is a common practice. Probably the most common is conan install . -pr gcc11 -s build_type=Debug
which would be fine as those already land-out under the same file tree.
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (5 by maintainers)
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
CMakePresets.json
? If I runconan install
several times I end up with: