question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] Multiple parallel profiles support in `cmake_layout()`

See original GitHub issue

Until 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 and build/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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lasotecommented, Jun 3, 2022

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.

No problem! if you reproduce again let me know.

Still, the directory layout could be optimized a bit 😉

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:

  • build/clang-14/generators
  • build/clang-14/debug
  • build/clang-14/release
  • build/gcc-11/generators
  • build/gcc-11/debug
  • build/gcc-11/release
0reactions
mpuszcommented, Jun 6, 2022

Is it possible to prevent repeating the same preset in CMakePresets.json? If I run conan install several times I end up with:

   ...,
    "buildPresets": [
        {
            "name": "Release-gcc-11",
            "configurePreset": "default-gcc-11",
            "configuration": "Release"
        },
        {
            "name": "Release-gcc-11",
            "configurePreset": "default-gcc-11",
            "configuration": "Release"
        }
    ],
   ...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog — conan 1.56.0 documentation
Feature : Implement a new [runenv] section in the Profile, to define the ... cmake_layout() layout helper to define a multi-platform CMake layout...
Read more >
Profiling Parallel Code - MATLAB & Simulink - MathWorks
Use the parallel profile to determine the calculation and communications time for each ... Calls, How many times the function was called on...
Read more >
How to create a parallel profile line in reference to an existing ...
How to create a parallel profile line in reference to an existing profile in Civil 3D as lowering the surface only works in...
Read more >
Multiple Work Profiles - Android Enterprise Community
Hi Olivier,. It's a long-standing feature request from myself also, but unfortunately is not currently something Google are working on. One day!
Read more >
CMake profiles | CLion Documentation - JetBrains
You can configure multiple profiles for your project in order to, ... On reloading CMake, all the profiles are reloaded in parallel.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found