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

[question] Components hide global definitions in layout method #3592

Open
1 task done
marausch opened this issue Feb 14, 2024 · 3 comments
Open
1 task done

[question] Components hide global definitions in layout method #3592

marausch opened this issue Feb 14, 2024 · 3 comments
Assignees
Milestone

Comments

@marausch
Copy link

marausch commented Feb 14, 2024

Environment details

  • Conan version: 2.0.17
  • Python version: 3.11.6

Description

Hi,

When using components in the layout method for a dependency module, it seems that what gets defined through self.cpp.package.includedirs, self.cpp.package.libdirs, and so on is ignored when CMake related file are generated by a conan install for a consumer of the module.

For example, consider a layout method of the dependency's Conanfile containing:

self.cpp.package.includedirs = ["inc"]

but no component related definitions.

In this case the conan_toolchain.cmake file generated for a consumer contains something like:

list(PREPEND CMAKE_INCLUDE_PATH "C:/c2/b/depenf073120889728/p/inc")

By adding just any single component related definition to the layout method, for example:

self.cpp.package.components["comp"].objects = ["crt0_comp"]

what gets generated in the consumer's conan_toolchain.cmake becomes like this:

list(PREPEND CMAKE_INCLUDE_PATH "C:/c2/b/depen532f33fab3b55/p/include")

i.e. with the default "include" instead of "inc", as if no self.cpp.package.includedirs had been defined.

To get the expected conan_toolchain.cmake we need to add the proper includedirs definition for the component:

self.cpp.package.components["comp"].includedirs = ["inc"]

The same thing is true for libdirs, resdirs and probably others too (I haven't tested them all).

I guess this might be the wanted behaviour, even if I expected the global definitions to be concatenated (in case) with the components related ones.

Thank you in advance for any clarification.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Feb 14, 2024
@memsharded
Copy link
Member

Hi @marausch

Thanks for your question.

Your observations are right, once components are defined, the global self.cpp_info.xxxdirs are completely ignored, and the components defaults are used instead. So if you want to change the components ones need to do self.cpp_info.components["mycomp"].includedirs = ["inc"] too.

I have tried to make it that way, because it would be a bit more intuitive, in conan-io/conan#13994. But I finally dropped it, too risky, almost impossible to do it without breaking.

@marausch
Copy link
Author

Hi @memsharded,

I was just asking because I probably didn't read the documentation thoroughly (I haven't found where this is explained in the documentation).

Thank you.

@memsharded memsharded transferred this issue from conan-io/conan Feb 16, 2024
@memsharded memsharded reopened this Feb 16, 2024
@memsharded memsharded added this to the 2 milestone Feb 16, 2024
@memsharded
Copy link
Member

Thats fair, moving this ticket to docs, lets try to add some clarification.

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

No branches or pull requests

2 participants