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

[develop2] conanfile.py with CMakeDeps in generate() method causes errors #540

Open
jcar87 opened this issue Jul 20, 2023 · 4 comments
Open
Assignees
Labels
Milestone

Comments

@jcar87
Copy link
Contributor

jcar87 commented Jul 20, 2023

When we have a conanfile.py (as opposed to a conanfile.txt), and CMakeDeps is instantiated in the generate() method (as opposed to as the generators) attribute, CMake configuration fails with the following error:

ERROR: conanfile.py: Error in generate() method, line 20
	deps.generate()
	ConanException: CMakeDeps is declared in the generators attribute, but was instantiated in the generate() method too. It should only be present in one of them.
CMake Error at conan_provider.cmake:386 (message):
  Conan install failed='1'
Call Stack (most recent call first):
  conan_provider.cmake:478 (conan_install)
  CMakeLists.txt:6 (find_package)
@memsharded memsharded added this to the develop2 milestone Jul 20, 2023
@rturrado
Copy link

I've been using the Conan plugin for CMake. Great job by the way! 🥳 So much needed and appreciated. 👏

In my case, I had to remove the two following lines in the generate function of the conanfile.py for the plugin to work:

deps = CMakeDeps(self)
deps.generate()

But that made my conan builds from the command line, outside CLion, to start failing. Adding those two lines back got my conan builds from the command line back working.

@memsharded
Copy link
Member

Thanks for the report @rturrado

What was exactly the error that made you remove the lines from generate()? Maybe the one saying that the generator is "repeated"?

@rturrado
Copy link

Thanks for the report @rturrado

What was exactly the error that made you remove the lines from generate()? Maybe the one saying that the generator is "repeated"?

Yes. I can post it exactly when I'm at my computer later, but it was saying something like: you cannot define this in two places, you already defined it at the generators...

@memsharded
Copy link
Member

Ok, that makes sense thanks!
This seems an overlook of the "package creation" flow, as cmake-conan is very focused on the "consumer" story, but this should be fixed. I am submitting #564, as a possible solution, but we might want to discuss the approach, can't guarantee it will be merged as-is, but we will try to look for a solution in the following days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants