-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build on macOS Mojave #1923
Changes from all commits
2ad6f07
c121905
ac3f5f1
2180fc4
c723f3f
2131023
d2a3c20
2e96aa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX) | ||
endif() | ||
endif(USE_OPENMP) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't use hardcoded paths for the first build attempt. Let's use hardcoded paths only after first attempt fail:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why is this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest, it is correct for macOS users to set cmake options for AppleClang with OpenMP. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @henry0312 @StrikerRUS What about something like this instead in README.md or whatever else for comments? (and let the user change the paths?) 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 bash -c 'cmake ..' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Laurae2 I think that is one of options that we take, but that won't allow us to run just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe... But if everything works (OK, worked before 10.14), why should we ask users do more things then needed? @henry0312 @Laurae2 Hmm, what do you think about new setup args Then we can do the following:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, no. |
||
'-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: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gist.github.com/henry0312/c2e0550caf7acfce2e60a24984c322e9#file-make1-log