Skip to content

[feature] New cmake_find_mode - Copy Project provided Config files. #18815

@tstrutz

Description

@tstrutz

What is your suggestion?

We have been integrating conan into our C++ workflows for a number of weeks now and have noticed what feels like an oversight in the way that the build system integrates with the cmake-conan workflow.

One of our applications generates <PROJECT_NAME>-Config.cmake and <PROJECT_NAME>-ConfigVersion.cmake files, and Conan suggests the "none" cmake_find_mode" should be sufficient to use these. However, we have run into major issues with the way Conan separates configurations into separate packages. With the current "none" feature, there will be TWO <PROJECT_NAME>-Config.cmake files, one for Release and Debug. This is a problem, because there actually needs to be one file that tells you where to locate both configurations. The real issue with the current implementation is because of the way find_package works, it will never find both especially when using a Multi-Configuration such as Ninja-Multi-Config generator, and so the project typically finds only the configuration that happens to be located first.

Additionally, we can't use the generated Config files Conan makes as ours define find_dependency calls for a bunch of dependencies that can't be managed by Conan such as Matlab, and other non-public projects. We also set some of our project's data paths in these files, so that a downstream project (sorta like a plugin) can import these paths.

I have a pull request here that implements a new "copy" mode that will essentially copy the <PROJECT_NAME>-Config.cmake and <PROJECT_NAME>-ConfigVersion.cmake and CMake-generated targets files for each built package to the conan generators folder when using the Conan CMake integration.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions