-
Notifications
You must be signed in to change notification settings - Fork 981
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] conan2 Use cmake-file-api to get all the project targets info? #11897
Comments
The cmake-file-api has already some code inside Conan, but it hasn't been made public yet, but you can have a look to the codebase. The reason is that it is not very complete, so a lot of information still need to be provided by users and that makes it confusing. And it doesn't seem to be getting enough attention, so we doubt it will mature enough to be complete anytime soon. I'll add it to the 2.X pool to revisit once 2.0 is out |
I'd like to take a look to it, Is this https://github.com/conan-io/conan/blob/develop2/conan/tools/cmake/file_api.py the right one? |
Yes, that one. The idea is to create an intermediate json representation format. |
I was thinking to something a bit more straightforward (easier?). Instead to do: def build(self):
file_api = CMakeFileAPI(self)
file_api.query(CMakeFileAPI.CODEMODELV2)
cmake = CMake(self)
cmake.configure()
reply = file_api.reply(CMakeFileAPI.CODEMODELV2)
package = reply.to_conan_package()
package.save()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, CppPackage.DEFAULT_FILENAME, self.build_folder, self.package_folder)
def package_info(self):
cpp_package = CppPackage.load(CppPackage.DEFAULT_FILENAME)
cpp_package.package_info(self) I'll do: def build(self):
file_api = CMakeFileAPI(self)
file_api.query(CMakeFileAPI.CODEMODELV2)
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
file_api = CMakeFileAPI(self)
file_api.set_package_info() Or even easier: def layout(self):
cmake_layout(self) # does all the CMakeFileAPI magic
def package_info(self):
cmake_package_info(self) # uses the CMakeFileAPI to setup all the stuff |
I agree that some parts of the current api can be simplified. But hiding it too much is not good either, as always, "explicit is better than implicit". Reading a recipe it should be more or less understandable what is happening. It is also critical to make explicit the intermediate json output, that decouples the origin from the actual package information, this feature will not happen without it. |
Are there plains to make this available in Conan 2 ? |
Hi @ashley-b We have already started to do some preparation of the basic Recovering the cmake-file-api is not a high priority, but being in the 2.X milestone means that it is in our roadmap/plans. |
Hi @memsharded Support for mechanically generating
It seems this link to a file in |
Hi all, The efforts of using CMake file API have shifted to using the CPS standardization proposal wip, in which we are actively involved, as well as Kitware, Bloomber, Microsoft, etc. See #16054. Also we did a talk about it last year in CppCon and we will have another talk about it this year in CppCon. |
Hi @memsharded, Just watched last year video, which was a great introduction to Common Package Specification. CPS seems to be the way forward with the issue of mechanically extracting the "package info" from CMake-generated package confi. Is there a dedicated issue for CPS related discussions in Conan? I might be interested to explore this a bit further, which raised a few questions questions already:
But this issue about CMake file-API may not be the right place. |
Hi @Adnn yes, I think you need to watch this year talk too, the moment it is live: https://cppcon2024.sched.com/event/1gZew/common-package-specification-cps-in-practice-a-full-round-trip-implementation-in-conan-c-package-manager So we already have in Conan some functionality that loads CPS files created by build systems, it was integrated in last release and we demo'ed it live in CppCon, reading CMake generated CPS files. It is still a but too early to release or document it, but if you are interested, you can look for We keep heavily investing into more CPS-compatible functionality, and the new CMakeDeps generator in #16964 is getting more and more close to CPS conventions ( So I am closing this ticket as not planned, even CMake is also investing in this way more than in the cmake-file-api, so this totally seems the way to go. Thanks for the feedback! |
In conan 1.x cmake projects with multiple targets are not very easy/nice to write recipes for (check vorbis, mpg123, etc.).
It will be great if conan 2 can use cmake-file-api to get all the info for that project.
The text was updated successfully, but these errors were encountered: