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] CLI command to discover the cmake_find_package filename from the Conan package name? #7525

Closed
thejohnfreeman opened this issue Aug 8, 2020 · 4 comments · Fixed by #7690
Assignees
Milestone

Comments

@thejohnfreeman
Copy link

The cmake_find_package generator writes a Find Module file that defines a target in a namespace. Each of these three names (filename, namespace, target) are configurable in cpp_info. For example,

        self.cpp_info.filename['cmake_find_package'] = 'BoostFile'
        self.cpp_info.names['cmake_find_package'] = 'BoostNamespace'
        self.cpp_info.name = 'BoostTarget'

will generate a file named FindBoostFile.cmake that is used like this:

find_package(BoostFile)
target_link_libraries(${target} BoostNamespace::BoostTarget)

Is there a CLI command that can print out these values given a package reference? Something like

$ conan inspect -a cpp_info.names.cmake_find_package boost/1.73.0@
@memsharded
Copy link
Member

I think this should be updated in the markdown generator: https://docs.conan.io/en/latest/reference/generators/markdown.html
(up to my knowledge this markdown generator has not been updated yet to account for these changes)

Using it would be:

$ conan install boost/1.73.0@ -g=markdown

And you get the file with the instructions for the different generators.

@thejohnfreeman
Copy link
Author

That's ok for a human, but I'm looking for something that can be easily consumed by a script.

@memsharded
Copy link
Member

Ok, lets add that data to the json generator, something like from:

  "dependencies": [
    {
      "version": "1.2.11",

      "exelinkflags": [],
      "frameworks": [],
      "framework_paths": [],
      "cppflags": [],
      "name": "zlib"
    }
  ],

Add:

  "dependencies": [
    {
      "version": "1.2.11",

      "exelinkflags": [],
      "frameworks": [],
      "framework_paths": [],
      "cppflags": [],
      "name": "zlib"
      "names": {"cmake_find_package": "xxxx", "pkg_config": "yyyy"}
      "filenames": {"cmake_find_package": "zzzz"}
    }
  ],

uilianries added a commit to uilianries/conan that referenced this issue Sep 9, 2020
Signed-off-by: Uilian Ries <uilianries@gmail.com>
uilianries added a commit to uilianries/conan that referenced this issue Sep 9, 2020
Signed-off-by: Uilian Ries <uilianries@gmail.com>
uilianries added a commit to uilianries/conan that referenced this issue Sep 18, 2020
Signed-off-by: Uilian Ries <uilianries@gmail.com>
uilianries added a commit to uilianries/conan that referenced this issue Sep 18, 2020
Signed-off-by: Uilian Ries <uilianries@gmail.com>
memsharded pushed a commit that referenced this issue Sep 21, 2020
* #7525 Show filenames in json

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #7525 Add basic test for markdown generator

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #7525 Re-use jinja instance

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #7525 Fix cmake find package name

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@memsharded
Copy link
Member

This has been added in #7690 and will be released in Conan 1.30

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