add CMakeLists options to disable building CLI, installing headers#5880
add CMakeLists options to disable building CLI, installing headers#5880
Conversation
| -v \ | ||
| --install-option=--gpu \ | ||
| $BUILD_DIRECTORY/dist/lightgbm-$LGB_VER.tar.gz \ | ||
| || exit -1 |
There was a problem hiding this comment.
The changes here in test.sh aren't strictly related to the CMakeLists.txt changes.
This isn't actually event changing anything about this script. Just breaking these arguments onto individual lines, to make the size of the diff in #5759 a bit smaller (and therefore those changes a bit easier to review).
| "Semicolon separated list of sanitizer names, e.g., 'address;leak'. \ | ||
| Supported sanitizers are address, leak, undefined and thread." | ||
| ) | ||
| option(BUILD_CLI "Build the 'lightbgm' command-line interface in addition to lib_lightgbm" ON) |
There was a problem hiding this comment.
Note that the new options BUILD_CLI and INSTALL_HEADERS both default to ON so that this PR preserves the current default behavior on master.
|
@guolinke @shiyu1994 can you please help with reviews on this and #5884 ? So I can hopefully continue making progress on #5061. |
|
Thank you! |
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Contributes to #5061.
Proposes adding 3 options to
CMakeLists.txt:__BUILD_FOR_PYTHON= indicate that lib_lightgbm is being built for use in a Python wheelBUILD_CLI= do / do not compile thelightgbmCLI when runningmakeormake installINSTALL_HEADERS= do/do not move LightGBM's headers intoCMAKE_INSTALL_PREFIX(e.g./usr/local/include/LightGBM/*.h)Benefits of this change
Prevents unnecessary compilation of the CLI when building the Python package with
scikit-build-core.Prevents unnecessary generation of Makefile code for targets that won't ever be used by the R and Python packages.
More Details
LightGBM's
CMakeLists.txtgenerates Makefile(s) wheremake/make installhas 3 effects:lib_lightgbm.{dll/so}+ install itlightgbm(the CLI) + install itWhen building for the R and Python packages, the steps about the CLI and installing headers aren't required. LightGBM currently avoids those in those contexts by running
make _lightgbminstead ofmakeormake install.LightGBM/python-package/setup.py
Line 174 in 1c873af
LightGBM/R-package/src/install.libs.R
Line 138 in 1c873af
To address #5061, in #5759 I'm proposing that LightGBM use
scikit-build-core(https://github.com/scikit-build/scikit-build-core) as its build backend.As of this writing, that project unconditionally runs
make installon theCMake-generated makefiles (docs link). With that tool, there's no way to say "just build the_lightgbmtarget".This PR's changes make it possible to use LightGBM's
CMakeLists.txtin a way thatmakeandmake installonly build the shared library.