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] Packaging fmtlib #121

Closed
ngrodzitski opened this issue Sep 27, 2019 · 6 comments
Closed

[question] Packaging fmtlib #121

ngrodzitski opened this issue Sep 27, 2019 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@ngrodzitski
Copy link
Contributor

Why fmt recepie removes cmake directory?

tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

With fmt/5.3.0@bincrafters/stable I was able to use find_package( fmt 5.3.0 REQUIRED ) in cmake. Trying to upgrade to fmt/6.0.0 breaks my cmake usage logic.

So what is the idiomatic way to introduce fmtlib in one's cmake project now?

@ngrodzitski ngrodzitski added the question Further information is requested label Sep 27, 2019
@danimtb
Copy link
Member

danimtb commented Sep 27, 2019

We know that using find_package and relying on the CMake behavior to find the dependencies is something that should be avoided in favor of the information provided by the package manager.

Conan has an abstraction over the packages build system and description by using generators. Those generators translate the information of the dependency graph and create a suitable file that can be consumed by your build system.

In the past, we have found that the logic of some of the find and config files lead to broken scenarios with other dependencies and hardcoded paths that would make the package broken when shared and consumed.

Thus, we think that Conan already provides ways to consume those packages in the same way by using cmake_find_package generator: https://docs.conan.io/en/latest/reference/generators/cmake_find_package.html
That way all the information is consistent in the graph and you also point to the exact dependency package you want to use.

Please take a look at the integrations section to learn how to use it: https://docs.conan.io/en/latest/integrations/build_system/cmake/cmake_find_package_generator.html

Finally, by not allowing these files (and others such as pkg-config) we make packages agnostic to the consumer as the logic of those files is not in the package but in the way the consumer wants the information.

@danimtb danimtb self-assigned this Sep 27, 2019
@danimtb
Copy link
Member

danimtb commented Oct 3, 2019

As this might be a recurrent question, I have added this to the FAQ section of the wiki: https://github.com/conan-io/conan-center-index/wiki/FAQ#why-are-cmake-findconfig-files-and-pkg-config-files-not-packaged

@ngrodzitski
Copy link
Contributor Author

ngrodzitski commented Oct 4, 2019

Thanks for clarification.
Consider it closed.

While this approach definitely works, there might be some issues while migrating to it, I've got the following issue with gtest. I introduce it as following:

find_package( GTest 1.8.0 REQUIRED)

And got en error:

CMake Error at /usr/local/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
  GTEST_MAIN_LIBRARY) (Required is at least version "1.8.0")
Call Stack (most recent call first):
  /usr/local/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.15/Modules/FindGTest.cmake:197 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:60 (find_package)

Using find_package( gtest 1.8.0 REQUIRED) avoids this issue.

@danimtb
Copy link
Member

danimtb commented Oct 7, 2019

Yes, this is something we are aware of and recently introduced a new field for recipes to declare a different name that can be later used by those generators.

In the case of the requirement of gtest/<version>, the recipe could declare:

    ...
    def package_info(self):
        self.cpp_info.name = "GTest"
        ...

The generator will pick that name and something like find_package(GTest <version> REQUIRED) should just work 😄

Check self.cpp_info.name here https://docs.conan.io/en/latest/reference/conanfile/attributes.html#cpp-info for more information

@jan-grimo
Copy link

@danimtb Could you please elaborate your answer regarding config files? The technical reason why config files are disavowed is not clear to me from the FAQ or the text here. Could you maybe provide some links to past issues?

@uilianries
Copy link
Member

uilianries commented Feb 17, 2020

@jargonzombies please take a look in conan-io/conan#6269 (comment)

artem-kamyshev pushed a commit to artem-kamyshev/conan-center-index that referenced this issue Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants