Skip to content

Using multiple Conan profiles in CLion #233

@radonish

Description

@radonish

Background:
We have 5 different targets and thus 5 different toolchains to build SW for those targets. There are 2 Conan profiles for each toolchain - 1 debug and 1 release. Thus, we have a total of 10 Conan profiles and would like to build for any of those profiles within CLion. My CLion CMake configuration looks like this:

Image

The CMake profiles reference the configured toolchains:

Image

Issue:
I'm trying to find the "right way" to pull in Conan profiles within CLion so settings within the profile (e.g. CXXFLAGS, LDFLAGS) get used when building.

Setting CONAN_HOST_PROFILE and CONAN_BUILD_PROFILE in the CLion CMake options ensures that the right packages get pulled in but does not impact the CXXFLAGS/LDFLAGS being used.

I noticed CMakeUserPresets.json files getting created at the project root and that they contained references to CMakePresets.json files for each profile that has ever been enabled:

Image

I updated one of the CMake profiles in the CLion configuration to additionally have the --preset conan-debug parameter as I saw that is the preset name automatically generated (by this plugin?). Since there are more than 1 CMakePresets.json files included, there are multiple definitions of the "conan-debug" preset. This results in a "Duplicate preset: conan-debug" error. If I remove one of the preset includes manually, I can use the --preset conan-debug parameter and the Conan profile's CXXFLAGS/LDFLAGS get used (by way of the generated Conan toolchain file).

Question:
Is the intention for users to use the --preset parameter to pull Conan profile settings in? Or should CMAKE_TOOLCHAIN_FILE be used directly somehow?

Also, if the plugin is generating the CMakePresets.json file, could it be updated to use unique names to avoid the multiple "conan-debug" name conflict? Perhaps they could use part of the CMake profile name?

Thanks in advance for any help!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions