Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add possibility to change the version written to XXXConfigVersion.cmake generated by CMakeDeps generator #14789

Closed
1 task done
nicosmd opened this issue Sep 20, 2023 · 6 comments · Fixed by #14808
Milestone

Comments

@nicosmd
Copy link
Contributor

nicosmd commented Sep 20, 2023

What is your suggestion?

Hey,

I would like to propose a feature for the CMakeDeps generator. It is basically a feature which is already available for other generators like PkgConfigDeps. Using PkgConfigDeps generator it is possible to influence the version written to the *.pc file by setting self.cpp_info.set_property("component_version", "1.14.12") in the package_info stage.
This is actually a very useful feature when creating some kind of wrapper packages like system packages, where the package version might be something like system but pointing to an actual version of a library. Therefore it would be great to have something like this for the CMakeDeps generator as well to make the actual version of a library transparent to CMake, I think.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Hi @nicosmd

Thanks for your feedback.

Quick question, how would you make it available for CMakeDeps consumers? Because the public output of the generated xxx-config.cmake files are targets like mypkg::mycomponent, but there is no standard property for versions of targets?

@nicosmd
Copy link
Contributor Author

nicosmd commented Sep 20, 2023

Hey @memsharded,

It is not related in particular to the components. Maybe I'm just misusing the component_version property of the PkgConfigDeps but I don't want to set the version for a specific component but for the package itself. For CMake it would be useful to be able to overwrite what is written to the xxxConfigVersion.cmake, which is used by cmake to determine the version of a package when calling find_package(XXX X.Y.Z) when the version detail is specified. I hope I got your question right.

@memsharded
Copy link
Member

There is already a new property:

self.cpp_info.set_property("cmake_config_version_compat", "AnyNewerVersion")

That defines what gets written in the xxxConfigVersion.cmake. In general you don't want to change the package version, you want to control the find_package() version compatibility policy, and that can be defined with cmake_config_version_compat, is this what you are looking for?

@nicosmd
Copy link
Contributor Author

nicosmd commented Sep 20, 2023

It's not exactly what I had in mind. I agree that in general you don't want to change the package version but I would say that there is at least one use case for it I would like to satisfy. When creating system packages, the version of the package is usually set to system and not the actual version of that library but in the xxxConfigVersion.cmake conan will currently set the package version of the package to system as well and there is currently no way to change this. It is possible to read in the actual version of a package since it is written e.g. in the corresponding *.pc file which is read during the package_info stage of the system package and I would like to provide CMake the actual version of that package to give it the chance to raise an error when there are incompatibilities.

@memsharded
Copy link
Member

Ok, I think I understand it better.

It feels a bit unusual. find_package() versions are not that spread, but specially for system-packages, I haven't seen people doing it, precisely because it is a bit of a pain to get the right version in your find_package() call, specially when you are building in different platforms in which the system version can be varying.

In any case, this seems possible, I think listening to the component_version property and using it in ConfigVersionTemplate seems doable, do you want to give it a try and contribute it?

@nicosmd
Copy link
Contributor Author

nicosmd commented Sep 20, 2023

You are right, I also haven't seen this much but at least for creating tests for those system packages it is useful to make sure everything is working as expected.

yes sure, I would really like to give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants