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

Documentation for components and cmake_find_package generator #1722

Merged
merged 3 commits into from Jun 9, 2020

Conversation

danimtb
Copy link
Member

@danimtb danimtb commented Jun 2, 2020

@danimtb danimtb added this to the 1.26 milestone Jun 2, 2020
@danimtb danimtb requested review from memsharded and jgsogo and removed request for memsharded June 2, 2020 16:02
@danimtb danimtb requested a review from memsharded June 2, 2020 16:07
Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know some of these comments are for the PR to the client itself... regarding this one, I think these are the places that need to be modified 👍

Target in Find<PKG-NAME>.cmake
------------------------------
Components
++++++++++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect previous variables (<PKG-NAME>_INCLUDE_DIRS, <PKG-NAME>_SYSTEM_LIBS,...) to be available too, so "if using components these variables will be added to the ones listed before:":

reference/generators/cmake_find_package.rst Outdated Show resolved Hide resolved
reference/generators/cmake_find_package.rst Outdated Show resolved Hide resolved
@danimtb danimtb closed this Jun 9, 2020
@danimtb danimtb reopened this Jun 9, 2020
@jgsogo jgsogo merged commit 05e3e21 into conan-io:develop Jun 9, 2020
@gmikhaile
Copy link

gmikhaile commented Jun 30, 2020

Trying new components feature, seems like I miss some detail.
I've created a project which has two targets, core.dll and runner.exe. Core.dll depends on Qt5::Core. Runner.exe depends on core.dll.

Also I've created a conan recipe conanfile.py.

I defined qt in requirements:

def requirements(self):
        self.requires("qt/e5.12.4@mikhail/testing", private=False)

In package_info I use components:

def package_info(self):
    self.cpp_info.components["core"].libs = ["core"]
    self.cpp_info.components["core"].requires = ["qt"]
    self.cpp_info.components["runner"].requires = ["core"]

On build I have error:

File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\conans\client\installer.py", line 571, in _call_package_info raise ConanException("%s package_info(): %s" % (str(conanfile), e)) conans.errors.ConanException: lexer/1.0.0@mikhail/testing package_info(): Package require 'qt' not used in components requires

I assume I miss some detail.

Link to the project

I would appreciate any advice or reference to read about.

@danimtb
Copy link
Member Author

danimtb commented Jun 30, 2020

There is an example here https://docs.conan.io/en/latest/reference/conanfile/attributes.html#cpp-info

self.cpp_info.components["crypto"].requires = ["zlib::zlib"]  # Depends on all components in zlib package

In your case, if you want a component to depend on the whole qt package requirement you will have to specify:

self.cpp_info.components["core"].requires = ["qt::qt"]

Please try that and let me know if it works. Thanks for trying this new feature!

@gmikhaile
Copy link

There is an example here https://docs.conan.io/en/latest/reference/conanfile/attributes.html#cpp-info

self.cpp_info.components["crypto"].requires = ["zlib::zlib"]  # Depends on all components in zlib package

In your case, if you want a component to depend on the whole qt package requirement you will have to specify:

self.cpp_info.components["core"].requires = ["qt::qt"]

Please try that and let me know if it works. Thanks for trying this new feature!

Thank you! It did help!

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 this pull request may close these issues.

None yet

4 participants