Skip to content

Commit eda39c8

Browse files
committed
dependencies.cmake - LightGBM dependency was added
1 parent 877a144 commit eda39c8

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

cmake/dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Project dependencies
22
find_package(Armadillo REQUIRED)
33
find_package(Boost REQUIRED COMPONENTS regex serialization)
4+
find_package(LIGHTGBM REQUIRED)
45
find_package(OpenMP REQUIRED)
56
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
67

cmake/modules/FindLIGHTGBM.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Find the LightGBM includes and library
2+
#
3+
# This module defines the following IMPORTED targets:
4+
#
5+
# LightGBM::lightgbm - The LightGBM library, if found.
6+
#
7+
# This module will set the following variables in your project:
8+
#
9+
# LIGHTGBM_INCLUDE_DIRS - where to find <LightGBM/c_api.h>, etc.
10+
# LIGHTGBM_FOUND - True if the LightGBM library has been found.
11+
12+
find_package(PkgConfig QUIET)
13+
if(PKG_CONFIG_FOUND)
14+
pkg_check_modules(PC_LIGHTGBM QUIET lightgbm)
15+
endif()
16+
17+
find_path(
18+
LIGHTGBM_INCLUDE_DIR lightgbm
19+
NAMES LightGBM/c_api.h
20+
HINTS ${PC_LIGHTGBM_INCLUDEDIR} ${PC_LIGHTGBM_INCLUDE_DIRS}
21+
PATH_SUFFIXES include
22+
)
23+
24+
if(PC_LIGHTGBM_VERSION)
25+
# Version extracted from pkg-config
26+
set(LIGHTGBM_VERSION_STRING ${PC_LIGHTGBM_VERSION})
27+
endif()
28+
29+
# Handle find_package() arguments (i.e. QUIETLY and REQUIRED) and set
30+
# LIGHTGBM_FOUND to TRUE if all listed variables are filled.
31+
include(FindPackageHandleStandardArgs)
32+
find_package_handle_standard_args(
33+
LIGHTGBM
34+
REQUIRED_VARS LIGHTGBM_INCLUDE_DIR
35+
VERSION_VAR LIGHTGBM_VERSION_STRING
36+
)
37+
38+
set(LIGHTGBM_INCLUDE_DIRS ${LIGHTGBM_INCLUDE_DIR})
39+
mark_as_advanced(LIGHTGBM_INCLUDE_DIR)
40+

src/wif/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(LIBWIF_SOURCES
22
classifiers/classifier.cpp
33
classifiers/ipPrefixClassifier.cpp
4+
classifiers/lightGBMClassifier.cpp
45
classifiers/mlpackClassifier.cpp
56
classifiers/regexClassifier.cpp
67
classifiers/scikitMlClassifier.cpp
@@ -9,6 +10,7 @@ set(LIBWIF_SOURCES
910
combinators/majorityCombinator.cpp
1011
combinators/sumCombinator.cpp
1112
filesystem/fileModificationChecker.cpp
13+
ml/lightGBMWrapper.cpp
1214
ml/mlpackModels/decisionTreeModel.cpp
1315
ml/mlpackModels/hoeffdingTreeModel.cpp
1416
ml/mlpackModels/linearSVMModel.cpp
@@ -45,13 +47,6 @@ if(BUILD_WITH_UNIREC)
4547
)
4648
endif()
4749

48-
if(BUILD_WITH_LIGHTGBM)
49-
list(APPEND LIBWIF_SOURCES
50-
classifiers/lightGBMClassifier.cpp
51-
ml/lightGBMWrapper.cpp
52-
)
53-
endif()
54-
5550
add_library(wif SHARED ${LIBWIF_SOURCES})
5651
target_link_libraries(wif PRIVATE ${LIBWIF_LIBS})
5752
target_include_directories(wif PUBLIC ${CMAKE_SOURCE_DIR}/include)

0 commit comments

Comments
 (0)