Git Product home page Git Product logo

Comments (6)

danimtb avatar danimtb commented on May 22, 2024 2

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.

from conan-center-index.

danimtb avatar danimtb commented on May 22, 2024 1

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

from conan-center-index.

uilianries avatar uilianries commented on May 22, 2024 1

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

from conan-center-index.

ngrodzitski avatar ngrodzitski commented on May 22, 2024

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.

from conan-center-index.

danimtb avatar danimtb commented on May 22, 2024

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

from conan-center-index.

jan-grimo avatar jan-grimo commented on May 22, 2024

@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?

from conan-center-index.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.