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] New MakeDeps generator and transitive dependencies #14691

Open
1 task
db4 opened this issue Sep 7, 2023 · 10 comments
Open
1 task

[question] New MakeDeps generator and transitive dependencies #14691

db4 opened this issue Sep 7, 2023 · 10 comments
Assignees

Comments

@db4
Copy link
Contributor

db4 commented Sep 7, 2023

What is your question?

To illustrate the problem consider the following conanfile.txt:

[requires]
cairo/1.17.4

For it conan install . -g MakeDeps generates the following fragment:

# cairo/1.17.4
CONAN_NAME_CAIRO = cairo
CONAN_VERSION_CAIRO = 1.17.4
CONAN_REFERENCE_CAIRO = cairo/1.17.4
CONAN_ROOT_CAIRO = D:/.conan2/b/cairo1902eee45304e/p

CONAN_INCLUDE_DIRS_CAIRO = $(CONAN_INCLUDE_DIR_FLAG)$(CONAN_ROOT_CAIRO)/include

CONAN_LIB_DIRS_CAIRO = $(CONAN_LIB_DIR_FLAG)$(CONAN_ROOT_CAIRO)/lib
...

Why CONAN_INCLUDE_DIRS_CAIRO doesn't include dependencies include dirs?

Of course, the problem is not specific to cairo package. MakeDeps never includes transitive dependencies to CONAN_INCLUDE_DIRS_pkg, CONAN_LIB_DIRS_pkg, CONAN_LIBS_pkg etc.

Have you read the CONTRIBUTING guide?

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

Hi @db4

Thanks for your question.

The XXX_CAIRO variables contain exclusively the information for the cairo package, not the transitive dependencies, that are defined in their own variables.

The same file contains at the and an aggregated set of variables that can be used instead of the individual ones, to add not only the direct dependencies but also the transitive dependencies, have you checked those?

@uilianries
Copy link
Member

@db4 Besides Cairo variables, each dependency is listed as individual variables too. As it may be tedious to include in your Makefile, you can use global variables instead:

include $(BUILD_FOLDER)/conandeps.mk

CXXFLAGS      += $(CONAN_CXXFLAGS) -std=c++11
CPPFLAGS      += $(addprefix -I, $(CONAN_INCLUDE_DIRS))
CPPFLAGS      += $(addprefix -D, $(CONAN_DEFINES))
LDFLAGS       += $(addprefix -L, $(CONAN_LIB_DIRS))
LDLIBS        += $(addprefix -l, $(CONAN_LIBS))
LDLIBS        += $(addprefix -l, $(CONAN_SYSTEM_LIBS))
EXELINKFLAGS  += $(CONAN_EXELINKFLAGS)

We have it documented (https://docs.conan.io/2/reference/tools/gnu/makedeps.html#generated-files) but not well detailed. It deserves an improved.

Plus, there is a PR with an example to be included in the documentation as soon as it gets merged: conan-io/examples2#115

@db4
Copy link
Contributor Author

db4 commented Sep 7, 2023

@memsharded

The same file contains at the and an aggregated set of variables that can be used instead of the individual ones, to add not only the direct dependencies but also the transitive dependencies, have you checked those?

Do you mean CONAN_INCLUDE_DIRS? Yes, but it's too wide. I need include dirs (lib dirs, libs, etc.) for a package and all its transitive dependencies.

@uilianries
Copy link
Member

uilianries commented Sep 7, 2023

@db4 Please, confirm/fix the generator that you are using NMakeDeps or MakeDeps? The issue title is different from the description. Plus, what Conan client version are you running?


Could you please elaborate more why can not you use CONAN_INCLUDE_DIRS and should be Cairo, as you are including only a single dependency?

@db4
Copy link
Contributor Author

db4 commented Sep 7, 2023

@uilianries
CONAN_INCLUDE_DIRS may be a bad example, CONAN_LIBS is much better. I don't like to link the whole bunch of dependencies to each and every target of my project. In the case of Cmake, that's what Conan-generated targets are made for.

@uilianries
Copy link
Member

to each and every target of my project

@db4 So you have multiple targets and want to link or not, specific dependencies?

@db4
Copy link
Contributor Author

db4 commented Sep 7, 2023

Yes, a consumer project with many targets and different dependencies.

@uilianries
Copy link
Member

@db4 Please, confirm/fix the generator that you are using NMakeDeps or MakeDeps? The issue title is different from the description. Plus, what Conan client version are you running?

@db4
Copy link
Contributor Author

db4 commented Sep 7, 2023

MakeDeps generator from Conan 2.0.10. Maybe the word "new" in the title is confusing, I meant that the generator was released just recently.

@uilianries
Copy link
Member

@db4 Your case sounds fair, it could be improved.

We could add transitive dependencies values (include, libs, ...) appended to their root node.

It may implicate in duplicated values, in case including same dependency as individual but also getting a ride from its consumer package. I don't see a way to avoid it by generators, ever CMake suffers it. But I don't think it should be considered a problem, but bad usage.

@memsharded WDYT about adding support for transitive deps in Make variables?

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

3 participants