Skip to content

Commit

Permalink
[lightgbm] Add open-source library lightgbm to vcpkg (microsoft#39395)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmith111 authored Jun 21, 2024
1 parent 2f4b9eb commit c4467cb
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ports/lightgbm/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO microsoft/LightGBM
REF v${VERSION}
SHA512 295ea23ec55164232f1dde6aa46bcfa616e2fe4852eb2e3492e681477a8d7757875d60379c4d463a35a6a9db56b1f4bce86b3a03bed56ea3d36aadb94a3b38eb
PATCHES
vcpkg_lightgbm_use_vcpkg_libs.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
gpu USE_GPU
)

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(BUILD_STATIC_LIB "OFF")
else()
set(BUILD_STATIC_LIB "ON")
endif()


vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DBUILD_STATIC_LIB=${BUILD_STATIC_LIB}
${FEATURE_OPTIONS}
)

vcpkg_cmake_install()

vcpkg_copy_tools(TOOL_NAMES lightgbm AUTO_CLEAN)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
29 changes: 29 additions & 0 deletions ports/lightgbm/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "lightgbm",
"version": "4.4.0",
"description": [
"A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms.",
"Designed to be distributed and efficient and comes with faster training speeds, higher efficiency, lower memory usage and support of parallel, distributed, and GPU learning."
],
"homepage": "https://github.com/microsoft/LightGBM",
"license": "Apache-2.0",
"supports": "!android & !osx & !uwp",
"dependencies": [
"eigen3",
"fast-double-parser",
"fmt",
{
"name": "vcpkg-cmake",
"host": true
}
],
"features": {
"gpu": {
"description": "GPU support using Boost.Compute",
"dependencies": [
"boost-compute",
"opencl"
]
}
}
}
66 changes: 66 additions & 0 deletions ports/lightgbm/vcpkg_lightgbm_use_vcpkg_libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3492289b..6284b6e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,18 +115,17 @@ if(USE_SWIG)
endif()
endif()

-set(EIGEN_DIR "${PROJECT_SOURCE_DIR}/external_libs/eigen")
-include_directories(${EIGEN_DIR})
+find_package(Eigen3 CONFIG REQUIRED)

# See https://gitlab.com/libeigen/eigen/-/blob/master/COPYING.README
add_definitions(-DEIGEN_MPL2_ONLY)
add_definitions(-DEIGEN_DONT_PARALLELIZE)

-set(FAST_DOUBLE_PARSER_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/external_libs/fast_double_parser/include")
-include_directories(${FAST_DOUBLE_PARSER_INCLUDE_DIR})
+find_package(fmt CONFIG REQUIRED)
+get_target_property(VCPKG_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES)
+set(FMT_INCLUDE_DIR ${VCPKG_INCLUDE_DIR}/fmt)

-set(FMT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/external_libs/fmt/include")
-include_directories(${FMT_INCLUDE_DIR})
+find_path(FAST_DOUBLE_PARSER_INCLUDE_DIR fast_double_parser.h)

if(__BUILD_FOR_R)
find_package(LibR REQUIRED)
@@ -181,15 +180,13 @@ if(USE_OPENMP)
endif()

if(USE_GPU)
- set(BOOST_COMPUTE_HEADER_DIR ${PROJECT_SOURCE_DIR}/external_libs/compute/include)
- include_directories(${BOOST_COMPUTE_HEADER_DIR})
find_package(OpenCL REQUIRED)
include_directories(${OpenCL_INCLUDE_DIRS})
message(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS})
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
endif()
- find_package(Boost 1.56.0 COMPONENTS filesystem system REQUIRED)
+ find_package(Boost 1.56.0 COMPONENTS filesystem system compute REQUIRED)
if(WIN32)
# disable autolinking in boost
add_definitions(-DBOOST_ALL_NO_LIB)
@@ -458,9 +455,11 @@ endif()

add_library(lightgbm_objs OBJECT ${SOURCES})

+target_link_libraries(lightgbm_objs PUBLIC Eigen3::Eigen fmt::fmt)
+
if(BUILD_CLI)
add_executable(lightgbm src/main.cpp src/application/application.cpp)
- target_link_libraries(lightgbm PRIVATE lightgbm_objs)
+ target_link_libraries(lightgbm PRIVATE lightgbm_objs Eigen3::Eigen fmt::fmt)
endif()

set(API_SOURCES "src/c_api.cpp")
@@ -471,6 +470,7 @@ if(__BUILD_FOR_R)
endif()

add_library(lightgbm_capi_objs OBJECT ${API_SOURCES})
+target_link_libraries(lightgbm_capi_objs PUBLIC Eigen3::Eigen fmt::fmt)

if(BUILD_STATIC_LIB)
add_library(_lightgbm STATIC)
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5368,6 +5368,10 @@
"baseline": "2020-11-24",
"port-version": 0
},
"lightgbm": {
"baseline": "4.4.0",
"port-version": 0
},
"lightningscanner": {
"baseline": "1.0.1",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/lightgbm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "e8a4ff8e712c8794cc650c722dfd9d65581c68bb",
"version": "4.4.0",
"port-version": 0
}
]
}

0 comments on commit c4467cb

Please sign in to comment.