зеркало из https://github.com/microsoft/LightGBM.git
Fix build on macOS Mojave (#1923)
* Fix build on macOS Mojave Fixed #1898 - https://iscinumpy.gitlab.io/post/omp-on-high-sierra/ - https://cliutils.gitlab.io/modern-cmake/chapters/packages/OpenMP.html - https://github.com/Homebrew/homebrew-core/pull/20589 * update setup.py * update docs * fix setup.py * update docs * update docs * update setup.py * update docs
This commit is contained in:
Родитель
b37065dbd5
Коммит
b96849918d
|
@ -211,8 +211,8 @@ endif(USE_MPI)
|
|||
|
||||
if(USE_OPENMP)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
TARGET_LINK_LIBRARIES(lightgbm ${OpenMP_libomp_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES(_lightgbm ${OpenMP_libomp_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX)
|
||||
TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
endif(USE_OPENMP)
|
||||
|
||||
|
|
|
@ -146,7 +146,19 @@ Only **Apple Clang** version 8.1 or higher is supported.
|
|||
|
||||
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
|
||||
mkdir build ; cd build
|
||||
|
||||
# For Mojave (10.14)
|
||||
cmake \
|
||||
-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 ..
|
||||
|
||||
make -j4
|
||||
|
||||
gcc
|
||||
|
@ -436,7 +448,20 @@ Only **Apple Clang** version 8.1 or higher is supported.
|
|||
|
||||
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
|
||||
mkdir build ; cd build
|
||||
|
||||
# For Mojave (10.14)
|
||||
cmake \
|
||||
-DUSE_MPI=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_MPI=ON ..
|
||||
|
||||
make -j4
|
||||
|
||||
gcc
|
||||
|
|
|
@ -118,8 +118,22 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, nomp=False,
|
|||
cmake_cmd.append("-DUSE_MPI=ON")
|
||||
if nomp:
|
||||
cmake_cmd.append("-DUSE_OPENMP=OFF")
|
||||
if system() == 'Darwin' and not nomp:
|
||||
cc = os.environ.get('CC')
|
||||
cxx = os.environ.get('CXX')
|
||||
if not (cc and cc.startswith('gcc') and cxx and cxx.startswith('g++')):
|
||||
# Apple Clang
|
||||
# https://github.com/Homebrew/homebrew-core/pull/20589
|
||||
cmake_cmd.extend([
|
||||
'-DOpenMP_C_FLAGS=-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include',
|
||||
'-DOpenMP_C_LIB_NAMES=omp',
|
||||
'-DOpenMP_CXX_FLAGS=-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include',
|
||||
'-DOpenMP_CXX_LIB_NAMES=omp',
|
||||
'-DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib'
|
||||
])
|
||||
if use_hdfs:
|
||||
cmake_cmd.append("-DUSE_HDFS=ON")
|
||||
|
||||
if system() in ('Windows', 'Microsoft'):
|
||||
if use_mingw:
|
||||
if use_mpi:
|
||||
|
|
Загрузка…
Ссылка в новой задаче