question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] generator for modern cmake

See original GitHub issue

Conan supports many cmake generators:

  • cmake
  • cmake_multi
  • cmake_paths
  • cmake_find_package
  • cmake_find_package_multi
  • CMakeDeps

Currently we use cmake and cmake_multi but they have a huge limitation (no components support). So I’m thinking to switch to cmake_find_package and cmake_find_package_multi but it seems that components support is also experimental. And then there is CMakeDeps which looks like a reimplementation of cmake_find_package

My understanding is that these different generators were created to simplify conan integration with existing cmake projects! But What is the most recommended generator to use if we do conan oriented modern cmake ?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:26 (20 by maintainers)

github_iconTop GitHub Comments

3reactions
memshardedcommented, Aug 30, 2021

I think we need some utility functions like get_generator or is_multi_configuration somewhere in conan.tools.cmake.*, because this logic will go out of sync with CMakeToolchain very soon if implemented in the every recipe. I mean all the new features like new msvc compiler id or Ninja Multiconfig generator will break it some day.

Yes, the idea is to mature first the main helpers like CMakeToolchain, etc., and as we internally factorize the utility functions, we will make them available, but better wait until things stabilize a bit more before publishing them.

1reaction
memshardedcommented, Aug 15, 2022

Hi @sully7

Yes, it is necessary to add find_package() calls in the CMakeLists.txt. This is exactly what that majority of users were pushing to have, a “transparent” CMake integration via find_package(). Do you mean that you would like a conandeps.cmake file that adds all the find_package() calls, so you can just included that file? In the worst case, this is something easily achievable with something like:

def generate(self):
     finds = ["find_package({} CONFIG REQUIRED)".format(d.ref.name) for d in self.dependencies.direct_host.values()]
     save(self, "conandeps.cmake", "\n".join(finds)
Read more comments on GitHub >

github_iconTop Results From Across the Web

More Modern CMake - GitHub Pages
Learn about build systems and build system generators. Understand why CMake is used. ... Answer this. Question: Does cmake build build anything?
Read more >
A very simple question - Usage - CMake Discourse
CMake refers to the build systems as 'generators' since CMake generates their ... And just like C++ there is a modern CMake and...
Read more >
Embracing Modern CMake - Stephen Kelly - YouTube
This talk will explore how to achieve some tasks using modern CMake idioms, as well as tooling and future directions.
Read more >
Modern CMake Tips - PSPDFKit
There are better ways to write CMake scripts. ... Modern CMake Tips ... Generator expressions are inline conditionals that are determined at the...
Read more >
download a copy as a PDF - Modern CMake
In short, here are the most likely questions in your mind if you are ... CMAKE_GENERATOR to control the default generator (CMake 3.15+)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found