Commit 414bb609 authored by Ilya Matiach's avatar Ilya Matiach Committed by Guolin Ke
Browse files

added LightGBM SWIG wrappers for macOS and updated docs (#2002)

* added LightGBM SWIG wrappers for macOS and updated docs

* updated installation instructions based on comments

* updated based on comments
parent 7ebf80f8
...@@ -55,6 +55,9 @@ if(USE_SWIG) ...@@ -55,6 +55,9 @@ if(USE_SWIG)
if(WIN32) if(WIN32)
FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/windows/x86_64") FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/windows/x86_64")
include_directories($ENV{JAVA_HOME}/include/win32) include_directories($ENV{JAVA_HOME}/include/win32)
elseif(APPLE)
FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/osx/x86_64")
include_directories($ENV{JAVA_HOME}/include/darwin)
else() else()
FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/linux/x86_64") FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/linux/x86_64")
include_directories($ENV{JAVA_HOME}/include/linux) include_directories($ENV{JAVA_HOME}/include/linux)
...@@ -196,6 +199,12 @@ if(USE_SWIG) ...@@ -196,6 +199,12 @@ if(USE_SWIG)
COMMAND cp "${PROJECT_SOURCE_DIR}/Release/*.dll" com/microsoft/ml/lightgbm/windows/x86_64 COMMAND cp "${PROJECT_SOURCE_DIR}/Release/*.dll" com/microsoft/ml/lightgbm/windows/x86_64
COMMAND "${Java_JAR_EXECUTABLE}" -cf lightgbmlib.jar com) COMMAND "${Java_JAR_EXECUTABLE}" -cf lightgbmlib.jar com)
endif() endif()
elseif(APPLE)
add_custom_command(TARGET _lightgbm_swig POST_BUILD
COMMAND "${Java_JAVAC_EXECUTABLE}" -d . java/*.java
COMMAND cp "${PROJECT_SOURCE_DIR}/*.dylib" com/microsoft/ml/lightgbm/osx/x86_64
COMMAND cp "${PROJECT_SOURCE_DIR}/lib_lightgbm_swig.jnilib" com/microsoft/ml/lightgbm/osx/x86_64/lib_lightgbm_swig.dylib
COMMAND "${Java_JAR_EXECUTABLE}" -cf lightgbmlib.jar com)
else() else()
add_custom_command(TARGET _lightgbm_swig POST_BUILD add_custom_command(TARGET _lightgbm_swig POST_BUILD
COMMAND "${Java_JAVAC_EXECUTABLE}" -d . java/*.java COMMAND "${Java_JAVAC_EXECUTABLE}" -d . java/*.java
......
...@@ -670,6 +670,82 @@ On Linux Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMake ...@@ -670,6 +670,82 @@ On Linux Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMake
cmake -DUSE_SWIG=ON .. cmake -DUSE_SWIG=ON ..
make -j4 make -j4
macOS
^^^^^
On macOS Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMake** and **Apple Clang** or **gcc**.
First, install `SWIG`_ and **Java** (also make sure that ``JAVA_HOME`` is set properly).
Then, either follow the **Apple Clang** or **gcc** installation instructions below.
Apple Clang
***********
Only **Apple Clang** version 8.1 or higher is supported.
1. Install `CMake`_ (3.12 or higher):
.. code::
brew install cmake
2. Install **OpenMP**:
.. code::
brew install libomp
3. Run the following commands:
.. code::
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
mkdir build ; cd build
# For Mojave (10.14)
cmake \
-DUSE_SWIG=ON \
-DAPPLE_OUTPUT_DYLIB=ON \
-DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
-DOpenMP_C_LIB_NAMES="omp" \
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
-DOpenMP_CXX_LIB_NAMES="omp" \
-DOpenMP_omp_LIBRARY=$(brew --prefix libomp)/lib/libomp.dylib \
..
# For High Sierra or earlier (<= 10.13)
cmake -DUSE_SWIG=ON -DAPPLE_OUTPUT_DYLIB=ON ..
make -j4
gcc
***
1. Install `CMake`_ (3.2 or higher):
.. code::
brew install cmake
2. Install **gcc**:
.. code::
brew install gcc
3. Run the following commands:
.. code::
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
export CXX=g++-7 CC=gcc-7 # replace "7" with version of gcc installed on your machine
mkdir build ; cd build
cmake -DUSE_SWIG=ON -DAPPLE_OUTPUT_DYLIB=ON ..
make -j4
Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.
.. |download artifacts| image:: ./_static/images/artifacts-not-available.svg .. |download artifacts| image:: ./_static/images/artifacts-not-available.svg
:target: https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html :target: https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment