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] CMake generators: Move includes of build_modules after targets are created in generated CMake find modules #7261

Closed
1 task done
TimSimpson opened this issue Jun 28, 2020 · 5 comments · Fixed by #8130

Comments

@TimSimpson
Copy link
Contributor

The attribute self.cpp_info.build_modules can be used to set CMake files which get included in the generated find modules created by cmake_find_package.

Today, these include statements are put before the targets which are defined by the generated find module files, rather than at the end of the file, which means the build modules script cannot interact with the exported targets directly.

@danimtb has suggested there may not have been a motivation in putting the build modules before the target, so if the is the case let's move them to the end of the file.

This would enable things like setting additional properties on the targets or creating clones or aliases of them.

@TimSimpson
Copy link
Contributor Author

cc @GordonJess

@jgsogo
Copy link
Contributor

jgsogo commented Jul 3, 2020

Hi! Is there any real use-case for this? For example, the target alias, IMO it is not something to be packaged with the library, it is something that belongs to the consumer

@jgsogo jgsogo self-assigned this Jul 3, 2020
@TimSimpson
Copy link
Contributor Author

I guess my main thinking is, if there is no great reason not to do it, and it offers some flexibility for people wanting to use build modules, then why not?

As for real use cases, my own is of course to create alias targets so I can name the CMake targets used by consumers of my own Conan packages anyway I want. I know upcoming features like this one could make that unnecessary, but it seemed worthwhile to make an issue to tackle the problem from this angle as well, especially since it appears so unintrusive to Conan itself.

I know @gordonjess mentioned wanting to set a custom property on the target, so maybe he could comment here too.

@jgsogo
Copy link
Contributor

jgsogo commented Jul 15, 2020

I've just realized that this issue was here and I opened another one: #7352

I'm copying here what I've written in the other one after talking with the team and I'll close that one:

This is a last-mile problem for CMake. Some packages provide CMake modules with some customization that doesn't fit the general conventions and we cannot keep adding more complexity to the cpp_info model:

If we really want to provide transparent integration, this last-mile details cannot be supported in the cpp_info, but they can be added to the build_modules, those files are included for all the CMake generates and they can populate other variables based on the value of existing ones and they could create custom targets (or alias)...

To be able to implement this feature, some work/research to be done:

  • include build_modules after creating the targets for cmake_find_package[_multi] generators.
  • build_modules need to know the generator used, so they know if targets are available or not (depending on the generator, or even depending on the TARGET argument to conan_basic_setup).

@jgsogo jgsogo changed the title [feature] Move includes of build_modules to after targets are created in generated CMake find modules [feature] CMake generators: Move includes of build_modules after targets are created in generated CMake find modules Jul 15, 2020
@Croydon
Copy link
Contributor

Croydon commented Aug 17, 2020

IIRC I struggled with the current behaviour too with either protobuf or grpc

👍

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

Successfully merging a pull request may close this issue.

3 participants