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] Indexing and building multiple recipes in correct order #15549

Closed
1 task done
pkitslaar opened this issue Jan 29, 2024 · 5 comments
Closed
1 task done

[question] Indexing and building multiple recipes in correct order #15549

pkitslaar opened this issue Jan 29, 2024 · 5 comments
Assignees

Comments

@pkitslaar
Copy link

pkitslaar commented Jan 29, 2024

What is your question?

I am converting a large project from plain CMake to be managed by conan. The structure of the project is as follows:

\CMakeLists.txt
\libA\CMakeLists.txt
\libB\CMakeLists.txt
etc..

In the various libA, libB can have dependencies on each other. The way this is currently handled is that in the master CMakeLists.txt there are multiple add_subdirectory(..) calls in the correct order so that dependent libraries are visited first before the library that consumes them.

I am converting this to conan so each libX is a conan package with its own conanfile.py. In the conanfile.py I indicate the dependencies using the requires(...) methods.

Is there a way to easily scan/index the entire project and find all the dependencies between the projects and come up with some superbuild command so all the libraries are build/created in the correct order?

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@AbrilRBS
Copy link
Member

Hi! Thanks a lot for your question.

First and foremost, Conan already manages your dependencies ordering as needed. This is the case for the conan install/conan create etc commands that calculate the dependency graph of the package you're targeting, based on the info you provide in the requires methods. Furthermore, in those cases Conan won't recompile packages which already have binaries present.

If what you need is the build order of the dependencies for any given package, then I'd recommend looking into the conan graph build-order command, which will output an ordered list of configurations, such that top-most dependencies are built before their dependants. We will add better documentation on this command in the near future, but for now feel free to ask any other question you might have regarding its usage :)

@AbrilRBS AbrilRBS self-assigned this Jan 29, 2024
@pkitslaar
Copy link
Author

Thank you for the answer. I believe for all these commands I need to point it to an explicit conanfile.py to kick-off the graph.
However, the problem is that it quickly stops because it does not know about the requirements since they were not build yet.

Let's say libB depends on libA. If I run conan graph build-order libB it would complain that it does not know about libA, so I somehow have to inform conan there is a libA in the first place. So, I was hoping there is some recursive indexing command that informs conan about the existence of the libA by somehow scanning the folders in my project.

@pkitslaar
Copy link
Author

I believe I have found what I need. I should either first run conan export on all the directories containing the recipes for my libraries or possible conan editable add . in each of the directories. Now conan knows about all the packages and can suggest the best build order using conan graph build-order. Does this make sense?

@AbrilRBS
Copy link
Member

AbrilRBS commented Feb 2, 2024

Hi @pkitslaar sorry for the delay.

I initially misunderstood your question and thought you meant how to extract the dependencies to build from within CMake itself, but your second message clarifies that a lot.

The approaches you mention are the current solutions for your use-case, but note that we plan to bring back the workspace feature to Conan 2 at some point, where multiple editable packages can be managed at once seamlessly, but for now the easiest way to tell Conan about a dependency name is to either export the recipe or create an editable out of it :)

@AbrilRBS
Copy link
Member

AbrilRBS commented Oct 7, 2024

Closing as solved. For workspace updates, follow #15992

@AbrilRBS AbrilRBS closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants