[c++] remove uses of '..' in headers#6409
Conversation
…o fix/include-paths
borchero
left a comment
There was a problem hiding this comment.
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. |
guolinke
left a comment
There was a problem hiding this comment.
Thank you, looks good to me!
|
Thank you! |
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
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 installor 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 -j4Compilation 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.soshould be able to just includeLightGBM/c_api.hto link to it. I tried with such a program, like this:Attempted to compile it like this:
clang++ \ -std=c++11 \ -o ./lgb-train \ -I/tmp/lightgbm/include \ -l_lightgbm \ -L/tmp/lightgbm/lib \ -Wl,-rpath,/tmp/lightgbm/lib \ ./main.cppThat fails like this:
On this branch, it succeeds, and the program runs successfully 😁
Notes for Reviewers
Why only
fast_double_parserandfmt? Isn't this a problem for Boost (external_libs/compute/) and Eigen (external_libs/Eigen)?For using LightGBM's C API, only
fast_double_parserandfmtheaders need to be available to#include <LightGBM/c_api.h>.