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

Allow LightGBM to be easily used in external projects via modern CMake style with find_package and target_link_libraries #4067

Closed
nims11 opened this issue Mar 12, 2021 · 5 comments

Comments

@nims11
Copy link

nims11 commented Mar 12, 2021

Summary

Generate pkg-config file for the library.

Motivation

pkg-config is a widely used way to provide linker flags and include directories for use in other projects. For example, with cmake, a project can just call find_package(LightGBM REQUIRED) and it will set the include directories and linker flags.

Note this applies to use cases when precompiled lightgbm is installed in a system/container. This doesn't apply to projects building with lightgbm with add_subdirectory.

Description

Generate a .pc file as part of the build.

References

https://people.freedesktop.org/~dbn/pkg-config-guide.html

@jameslamb
Copy link
Collaborator

Thanks very much for your interest in LightGBM! The guide you attached looks helpful.

Could you point to a project that you use that has pkg-config support, so that anyone picking up this feature could look at the code there as a reference?

@nims11
Copy link
Author

nims11 commented Mar 12, 2021

zlib has pkg-config support. They do this by having a zlib.pc.cmakein template which is used to generate the pc file during build (relevant CMakelists.txt lines). Afaik, this is a common way of adding pkg-config support.

I will also be happy to contribute if you think it is worth having.

@StrikerRUS
Copy link
Collaborator

For example, with cmake, a project can just call find_package(LightGBM REQUIRED) and it will set the include directories and linker flags.

For the reference, see how huge refactoring was required for XGBoost to achieve this goal: dmlc/xgboost#4323 (comment).

To be honest, I'm quite sceptical about that pkg-config will do all the magic for us.

@StrikerRUS StrikerRUS changed the title Add pkg-config support Allow LightGBM to be easily used in external projects via modern CMake style with find_package and target_link_libraries Mar 27, 2021
@StrikerRUS
Copy link
Collaborator

Closed in favor of being in #2302. We decided to keep all feature requests in one place.

Welcome to contribute this feature! Please re-open this issue (or post a comment if you are not a topic starter) if you are actively working on implementing this feature.

@StrikerRUS
Copy link
Collaborator

Also, for pkg-config example refer to dmlc/xgboost#5744.

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