-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
0001-Fix-CMakeLists.txt.patch
174 lines (163 loc) · 5.64 KB
/
0001-Fix-CMakeLists.txt.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
From d1a2140a9455d3364e2b2d6860e4e7333ac9c6ca Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Sun, 10 Mar 2024 01:51:24 +0700
Subject: [PATCH] Fix CMakeLists.txt
---
CMakeLists.txt | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git CMakeLists.txt CMakeLists.txt
index 1ff289b9..43f6bcea 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -35,11 +35,7 @@
project(lightgbm LANGUAGES C CXX)
-if(BUILD_CPP_TEST)
- set(CMAKE_CXX_STANDARD 14)
-else()
- set(CMAKE_CXX_STANDARD 11)
-endif()
+set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
@@ -115,19 +111,16 @@
endif()
endif()
-set(EIGEN_DIR "${PROJECT_SOURCE_DIR}/external_libs/eigen")
+find_package(fmt REQUIRED)
+include_directories(${LIBFMT_DIR})
+
+find_package(Eigen3 REQUIRED NO_MODULE)
include_directories(${EIGEN_DIR})
# 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})
-
-set(FMT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/external_libs/fmt/include")
-include_directories(${FMT_INCLUDE_DIR})
-
if(__BUILD_FOR_R)
find_package(LibR REQUIRED)
message(STATUS "LIBR_EXECUTABLE: ${LIBR_EXECUTABLE}")
@@ -159,24 +152,7 @@
endif()
if(USE_OPENMP)
- if(APPLE)
- find_package(OpenMP)
- if(NOT OpenMP_FOUND)
- # libomp 15.0+ from brew is keg-only, so have to search in other locations.
- # See https://github.com/Homebrew/homebrew-core/issues/112107#issuecomment-1278042927.
- execute_process(COMMAND brew --prefix libomp
- OUTPUT_VARIABLE HOMEBREW_LIBOMP_PREFIX
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include")
- set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include")
- set(OpenMP_C_LIB_NAMES omp)
- set(OpenMP_CXX_LIB_NAMES omp)
- set(OpenMP_omp_LIBRARY ${HOMEBREW_LIBOMP_PREFIX}/lib/libomp.dylib)
- find_package(OpenMP REQUIRED)
- endif()
- else()
- find_package(OpenMP REQUIRED)
- endif()
+ find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
@@ -707,83 +683,6 @@
set(CMAKE_INSTALL_PREFIX "lightgbm")
endif()
-# The macOS linker puts an absolute path to linked libraries in lib_lightgb.dylib.
-# This block overrides that information for LightGBM's OpenMP dependency, to allow
-# finding that library in more places.
-#
-# This reduces the risk of runtime issues resulting from multiple libomp.dylib being loaded.
-#
-if(APPLE AND USE_OPENMP)
- # store path to libomp found at build time in a variable
- get_target_property(
- OpenMP_LIBRARY_LOCATION
- OpenMP::OpenMP_CXX
- INTERFACE_LINK_LIBRARIES
- )
- # get just the filename of that path
- # (to deal with the possibility that it might be 'libomp.dylib' or 'libgomp.dylib' or 'libiomp.dylib')
- get_filename_component(
- OpenMP_LIBRARY_NAME
- ${OpenMP_LIBRARY_LOCATION}
- NAME
- )
- # get directory of that path
- get_filename_component(
- OpenMP_LIBRARY_DIR
- ${OpenMP_LIBRARY_LOCATION}
- DIRECTORY
- )
- # get exact name of the library in a variable
- get_target_property(
- __LIB_LIGHTGBM_OUTPUT_NAME
- _lightgbm
- OUTPUT_NAME
- )
- if(NOT __LIB_LIGHTGBM_OUTPUT_NAME)
- set(__LIB_LIGHTGBM_OUTPUT_NAME "lib_lightgbm")
- endif()
-
- if(CMAKE_SHARED_LIBRARY_SUFFIX_CXX)
- set(
- __LIB_LIGHTGBM_FILENAME "${__LIB_LIGHTGBM_OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_CXX}"
- CACHE INTERNAL "lightgbm shared library filename"
- )
- else()
- set(
- __LIB_LIGHTGBM_FILENAME "${__LIB_LIGHTGBM_OUTPUT_NAME}.dylib"
- CACHE INTERNAL "lightgbm shared library filename"
- )
- endif()
-
- # Override the absolute path to OpenMP with a relative one using @rpath.
- #
- # This also ensures that if a libomp.dylib has already been loaded, it'll just use that.
- add_custom_command(
- TARGET _lightgbm
- POST_BUILD
- COMMAND
- install_name_tool
- -change
- ${OpenMP_LIBRARY_LOCATION}
- "@rpath/${OpenMP_LIBRARY_NAME}"
- "${__LIB_LIGHTGBM_FILENAME}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMENT "Replacing hard-coded OpenMP install_name with '@rpath/${OpenMP_LIBRARY_NAME}'..."
- )
- # add RPATH entries to ensure the loader looks in the following, in the following order:
- #
- # - /opt/homebrew/opt/libomp/lib (where 'brew install' / 'brew link' puts libomp.dylib)
- # - ${OpenMP_LIBRARY_DIR} (wherever find_package(OpenMP) found OpenMP at build time)
- #
- set_target_properties(
- _lightgbm
- PROPERTIES
- BUILD_WITH_INSTALL_RPATH TRUE
- INSTALL_RPATH "/opt/homebrew/opt/libomp/lib;${OpenMP_LIBRARY_DIR}"
- INSTALL_RPATH_USE_LINK_PATH FALSE
- )
-endif()
-
install(
TARGETS _lightgbm
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
@@ -796,13 +695,4 @@
DIRECTORY ${LightGBM_HEADER_DIR}/LightGBM
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)
- install(
- FILES ${FAST_DOUBLE_PARSER_INCLUDE_DIR}/fast_double_parser.h
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/LightGBM/utils
- )
- install(
- DIRECTORY ${FMT_INCLUDE_DIR}/
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/LightGBM/utils
- FILES_MATCHING PATTERN "*.h"
- )
endif()