-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[c++] remove uses of '..' in headers #6409
Conversation
…o fix/include-paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have little CMake knowledge but no relative paths makes sense to me 😄
No problem, thanks for taking a look! I've spent a lot of time over the last 6 months getting more familiar with CMake, hopefully will be able to bring more simplifications like this one here. To be sure about this, let's get another review from either @guolinke or @shiyu1994 before merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks good to me!
Thank you! |
Contributes to #5957
Contributes to #6261
Contributes to #6379
Some of the project's headers use relative paths:
LightGBM/include/LightGBM/utils/common.h
Lines 33 to 34 in 28536a0
This causes problems for anyone wanting to use and install
lib_lightgbm.so
+ LightGBM headers to build their own program. Like this:As of the changes on this branch,
make install
or similar with LightGBM will install the headers with the following layout:How I tested this
Compiled a small test C++ program interacting with LightGBM through its C API.
details (click me)
On my mac, tried building the library and installing it to
/tmp/lightgbm
, like this:cmake \ -B build \ -S . \ -DUSE_OPENMP=OFF \ -DCMAKE_INSTALL_PREFIX=/tmp/lightgbm cmake --build build --target install -j4
Compilation succeeded (in this case, using AppleClang 15) and the library and its headers were installed to
/tmp/lightgbm
.Ideally, a program wanting to use
lib_lightgbm.so
should be able to just includeLightGBM/c_api.h
to link to it. I tried with such a program, like this:Attempted to compile it like this:
That fails like this:
On this branch, it succeeds, and the program runs successfully 😁
Notes for Reviewers
Why only
fast_double_parser
andfmt
? Isn't this a problem for Boost (external_libs/compute/
) and Eigen (external_libs/Eigen
)?For using LightGBM's C API, only
fast_double_parser
andfmt
headers need to be available to#include <LightGBM/c_api.h>
.