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] Setting specific generator for dependency. #15591

Closed
1 task done
ottmar-zittlau opened this issue Feb 4, 2024 · 2 comments
Closed
1 task done

[question] Setting specific generator for dependency. #15591

ottmar-zittlau opened this issue Feb 4, 2024 · 2 comments
Assignees

Comments

@ottmar-zittlau
Copy link

What is your question?

Hi,

I'm currently trying to update minizip-ng.
Previously we used a custom written recipe that worked fine with the cmake_paths-generator.
Now, I'm trying to use the minizip-ng recipe from conan center (https://github.com/conan-io/conan-center-index/blob/master/recipes/minizip-ng/all/conanfile.py). However, this doesn't work with the cmake_paths generator.

If I understand correctly, there is no minizip-config.cmake file contained in the package, so it relies on conan to generate it.
I then tried to use CMakeDeps - however, this generator "overwrites" all the cmake-config files contained in the packages, creating additional problems. I found a question with the exact same problem: #7118 - however, I don't understand the solution #12609. I also don't understand the documentation: https://docs.conan.io/1/reference/conanfile/tools/cmake/cmakedeps.html#set-property.

Maybe a detail on my issues with CMakeDeps - I use the "cmake_find_mode=None"-pattern (https://docs.conan.io/1/reference/conanfile/tools/cmake/cmakedeps.html#disable-cmakedeps-for-installed-cmake-configuration-files) quite a lot in my custom recipes, because this makes the most sense for me. However, when I use CMakeDeps these packages are ignored and if I understand correctly, I would then need to use the "ConanToolChain"-generator to get a hold of these packages, too. However, the toolchain-generator would be quite inconvenient for me, because I would need to always run conan on the command line before starting my IDE - and currently everything works fine from within CMake.

I tried mixing "cmake_paths" and cmake_find_package", but "cmake_find_packages" seems to generate find-package-files for each dependency.

So my questions are:

  1. Is it possible to make minizip-ng work with the cmake_paths generator.
  2. Is it possible to configure CMakeDeps so that I can add packages with "cmake_find_mode=None" without using a toolchain file? Is there maybe something planned that can achieve this?
  3. Is it possible to tell "cmake_find_package" not to create any cmake-files for certain dependencies? Would it be possible to use "cmake_paths" for these excluded dependencies?
  4. Is there a recommended approach for this?

Thanks and best regards
oz

Have you read the CONTRIBUTING guide?

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

Hi @ottmar-zittlau

Thanks for your question.

I tried mixing "cmake_paths" and cmake_find_package", but "cmake_find_packages" seems to generate find-package-files for each dependency.

Please don't use these generators, they are legacy and superseded long time ago by CMakeDeps + CMakeToolchain

Then, I am not sure I understood the issue. The recipes in ConanCenter do not create xxx-config.cmake files. Does it mean that you are working with a fork of conan-center-index and you are modifying the recipes and creating the packages from it? You did in the past, but you no longer want to do it and then now want to use the conan-center-index one?

  1. Is it possible to make minizip-ng work with the cmake_paths generator.

cmake_paths is legacy and not supported. But recipes in ConanCenter never supported cmake_paths, so if you are working from a fork, then things should keep working. I am afraid that I am missing something

  1. Is it possible to configure CMakeDeps so that I can add packages with "cmake_find_mode=None" without using a toolchain file? Is there maybe something planned that can achieve this?

If cmake_find_mode=None, CMakeDeps is useless and not related. CMakeDeps is responsible for creating the xxx-config.cmake files for the dependencies. If you want to use the xxxx-config.cmake files inside packages (for custom recipes that create that file, not conan-center-index recipes), then the only way to inject the location of these files to be found is a toolchain file. You can generate your own one in generate() or use the built-in CMakeToolchain one

  1. Is there a recommended approach for this?

Yes, using in-package xxx-config.cmake files (for custom recipes) is straightforward, the recommendation is:

  • In the recipe add the folder for this file to self.cpp_info.builddirs
  • You can optionally do the self.cpp_info.set_property("cmake_find_mode", "none") in the recipe
  • In the consumer side, using generators = "CMakeToolchain" will automatically manage to pass the folders of the dependencies, so find_package() finds them

@ottmar-zittlau
Copy link
Author

Thanks again for your quick reply. You are right, I'm currently trying to migrate custom built recipes to those from the conan-center. I will follow your advice and focus on CMakeDeps from now on.

I also figured out, that minizip didn't work for me, because it was integrated using tool_requires.

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

No branches or pull requests

2 participants