Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
1c8a7abd
Unverified
Commit
1c8a7abd
authored
Jun 08, 2023
by
James Lamb
Committed by
GitHub
Jun 08, 2023
Browse files
[c++] support building with Ninja on Linux (#5910)
parent
fe69fa9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
34 deletions
+51
-34
cmake/IntegratedOpenCL.cmake
cmake/IntegratedOpenCL.cmake
+37
-34
docs/Installation-Guide.rst
docs/Installation-Guide.rst
+14
-0
No files found.
cmake/IntegratedOpenCL.cmake
View file @
1c8a7abd
...
@@ -56,7 +56,31 @@ include(ExternalProject)
...
@@ -56,7 +56,31 @@ include(ExternalProject)
include
(
ProcessorCount
)
include
(
ProcessorCount
)
ProcessorCount
(
J
)
ProcessorCount
(
J
)
set
(
BOOST_BASE
"
${
PROJECT_BINARY_DIR
}
/Boost"
)
set
(
BOOST_BASE
"
${
PROJECT_BINARY_DIR
}
/Boost"
)
set
(
BOOST_INCLUDE
"
${
BOOST_BASE
}
/source"
CACHE PATH
""
)
set
(
BOOST_LIBRARY
"
${
BOOST_BASE
}
/source/stage/lib"
CACHE PATH
""
)
if
(
WIN32
)
if
(
WIN32
)
if
(
MSVC
)
if
(
${
MSVC_VERSION
}
GREATER 1929
)
message
(
FATAL_ERROR
"Unrecognized MSVC version number:
${
MSVC_VERSION
}
"
)
elseif
(
${
MSVC_VERSION
}
GREATER 1919
)
set
(
MSVC_TOOLCHAIN_ID
"142"
)
elseif
(
${
MSVC_VERSION
}
GREATER 1909
)
set
(
MSVC_TOOLCHAIN_ID
"141"
)
elseif
(
${
MSVC_VERSION
}
GREATER 1899
)
set
(
MSVC_TOOLCHAIN_ID
"140"
)
else
()
message
(
FATAL_ERROR
"Unrecognized MSVC version number:
${
MSVC_VERSION
}
"
)
endif
()
list
(
APPEND
BOOST_BUILD_BYPRODUCTS
${
BOOST_LIBRARY
}
/libboost_filesystem-vc
${
MSVC_TOOLCHAIN_ID
}
-mt-x64-
${
BOOST_VERSION_UNDERSCORE
}
.lib
${
BOOST_LIBRARY
}
/libboost_system-vc
${
MSVC_TOOLCHAIN_ID
}
-mt-x64-
${
BOOST_VERSION_UNDERSCORE
}
.lib
${
BOOST_LIBRARY
}
/libboost_chrono-vc
${
MSVC_TOOLCHAIN_ID
}
-mt-x64-
${
BOOST_VERSION_UNDERSCORE
}
.lib
)
else
()
message
(
FATAL_ERROR
"Integrated OpenCL build is not yet available for MinGW"
)
endif
()
set
(
BOOST_BOOTSTRAP
"
${
BOOST_BASE
}
/source/bootstrap.bat"
)
set
(
BOOST_BOOTSTRAP
"
${
BOOST_BASE
}
/source/bootstrap.bat"
)
set
(
BOOST_BUILD
"
${
BOOST_BASE
}
/source/b2.exe"
)
set
(
BOOST_BUILD
"
${
BOOST_BASE
}
/source/b2.exe"
)
set
(
BOOST_FLAGS
""
)
set
(
BOOST_FLAGS
""
)
...
@@ -64,6 +88,13 @@ else()
...
@@ -64,6 +88,13 @@ else()
set
(
BOOST_BOOTSTRAP
"
${
BOOST_BASE
}
/source/bootstrap.sh"
)
set
(
BOOST_BOOTSTRAP
"
${
BOOST_BASE
}
/source/bootstrap.sh"
)
set
(
BOOST_BUILD
"
${
BOOST_BASE
}
/source/b2"
)
set
(
BOOST_BUILD
"
${
BOOST_BASE
}
/source/b2"
)
set
(
BOOST_FLAGS
"-fPIC"
)
set
(
BOOST_FLAGS
"-fPIC"
)
list
(
APPEND
BOOST_BUILD_BYPRODUCTS
${
BOOST_LIBRARY
}
/libboost_filesystem.a
${
BOOST_LIBRARY
}
/libboost_system.a
${
BOOST_LIBRARY
}
/libboost_chrono.a
)
endif
()
endif
()
list
(
list
(
APPEND
APPEND
...
@@ -150,41 +181,13 @@ ExternalProject_Add(
...
@@ -150,41 +181,13 @@ ExternalProject_Add(
threading=multi
threading=multi
cxxflags=
"
${
BOOST_FLAGS
}
"
cxxflags=
"
${
BOOST_FLAGS
}
"
INSTALL_COMMAND
""
INSTALL_COMMAND
""
# BUILD_BYPRODUCTS is necessary to support 'Ninja' builds.
# ref:
# - https://cmake.org/cmake/help/latest/module/ExternalProject.html
# - https://stackoverflow.com/a/65803911/3986677
BUILD_BYPRODUCTS
${
BOOST_BUILD_BYPRODUCTS
}
)
)
set
(
BOOST_INCLUDE
"
${
BOOST_BASE
}
/source"
CACHE PATH
""
)
set
(
BOOST_LIBRARY
"
${
BOOST_BASE
}
/source/stage/lib"
CACHE PATH
""
)
list
(
APPEND INTEGRATED_OPENCL_INCLUDES
${
BOOST_INCLUDE
}
)
list
(
APPEND INTEGRATED_OPENCL_INCLUDES
${
BOOST_INCLUDE
}
)
if
(
WIN32
)
list
(
APPEND INTEGRATED_OPENCL_LIBRARIES
${
BOOST_BUILD_BYPRODUCTS
}
)
if
(
MSVC
)
if
(
${
MSVC_VERSION
}
GREATER 1929
)
message
(
FATAL_ERROR
"Unrecognized MSVC version number:
${
MSVC_VERSION
}
"
)
elseif
(
${
MSVC_VERSION
}
GREATER 1919
)
set
(
MSVC_TOOLCHAIN_ID
"142"
)
elseif
(
${
MSVC_VERSION
}
GREATER 1909
)
set
(
MSVC_TOOLCHAIN_ID
"141"
)
elseif
(
${
MSVC_VERSION
}
GREATER 1899
)
set
(
MSVC_TOOLCHAIN_ID
"140"
)
else
()
message
(
FATAL_ERROR
"Unrecognized MSVC version number:
${
MSVC_VERSION
}
"
)
endif
()
list
(
APPEND
INTEGRATED_OPENCL_LIBRARIES
${
BOOST_LIBRARY
}
/libboost_filesystem-vc
${
MSVC_TOOLCHAIN_ID
}
-mt-x64-
${
BOOST_VERSION_UNDERSCORE
}
.lib
${
BOOST_LIBRARY
}
/libboost_system-vc
${
MSVC_TOOLCHAIN_ID
}
-mt-x64-
${
BOOST_VERSION_UNDERSCORE
}
.lib
${
BOOST_LIBRARY
}
/libboost_chrono-vc
${
MSVC_TOOLCHAIN_ID
}
-mt-x64-
${
BOOST_VERSION_UNDERSCORE
}
.lib
)
else
()
message
(
FATAL_ERROR
"Integrated OpenCL build is not yet available for MinGW"
)
endif
()
else
()
list
(
APPEND
INTEGRATED_OPENCL_LIBRARIES
${
BOOST_LIBRARY
}
/libboost_filesystem.a
${
BOOST_LIBRARY
}
/libboost_system.a
${
BOOST_LIBRARY
}
/libboost_chrono.a
)
endif
()
set
(
BUILD_SHARED_LIBS ON CACHE BOOL
""
FORCE
)
set
(
BUILD_SHARED_LIBS ON CACHE BOOL
""
FORCE
)
docs/Installation-Guide.rst
View file @
1c8a7abd
...
@@ -133,6 +133,20 @@ On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
...
@@ -133,6 +133,20 @@ On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.
Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.
Using ``Ninja``
^^^^^^^^^^^^^^^
On Linux, LightGBM can also be built with `Ninja <https://ninja-build.org/>`__ instead of ``make``.
.. code:: sh
git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
mkdir build
cd build
cmake -G 'Ninja' ..
ninja -j2
macOS
macOS
~~~~~
~~~~~
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment