Skip to content

[feature] CMakeToolchain generator doesn't adequately represent settings nor does it follow a standard method of overriding C, CXX, and linker flags #9779

Open
@jwillikers

Description

@jwillikers

The CMakeToolchain generator lacks critical functionality for implementing various Conan settings from the settings.yaml file, and it doesn't provide adequate control for consumers to control settings across dependencies.
The new CMakeToolchain generator is very helpful for orchestrating building and packaging CMake projects, but isn't robust enough to properly propagate settings from consumers to their dependencies.
Environment variables appear to be the only way to adequately propagate necessary compiler settings across dependencies using various build systems.
The new CMakeToolchain generator doesn't use the flags from these variables, but instead requires injecting a toolchain file for a dependency to inherit specific settings.
This seems to go against the idea of Conan's settings / profiles being used to influence configurations of dependencies across various projects and their dependencies since its specific to both the underlying build system of each project and also the Conan generators used by the project.

For a simple bare-metal embedded project which doesn't wish to modify the recipes for all of its dependencies, it must use only CMake dependencies if it wishes to use the CMakeToolchain generator and it has to do this through the profile configuration of either user_toolchain or toolchain_file.
This requires manually translating Conan settings to compiler flags in a toolchain file, which is error-prone and redundant since the compiler flags are capable of being deduced from the Conan settings configured in profiles, such as the architecture being translated to the necessary -m flags.

To properly translate Conan settings to compiler flags in the CMakeToolchain, the user can control the templating of the default CMakeToolchain generator, but this must be done for every single dependency and even using python_requires this just isn't feasible for people that want to use existing package recipes from Conan Center.

It seems like there should be way more settings in settings.yaml to translate down to all the various compiler flags for this to work and / or a standard way to inject arbitrary C, CXX, and linker flags across all the various build-system generators directly from profiles.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions