File tree Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -171,8 +171,24 @@ if (USE_OPENMP)
171
171
# Require CMake 3.16+ on Mac OSX, as previous versions of CMake had trouble locating
172
172
# OpenMP on Mac. See https://github.com/dmlc/xgboost/pull/5146#issuecomment-568312706
173
173
cmake_minimum_required (VERSION 3.16 )
174
- endif (APPLE )
175
- find_package (OpenMP REQUIRED )
174
+ find_package (OpenMP )
175
+ if (NOT OpenMP_FOUND )
176
+ # Try again with extra path info; required for libomp 15+ from Homebrew
177
+ execute_process (COMMAND brew --prefix libomp
178
+ OUTPUT_VARIABLE HOMEBREW_LIBOMP_PREFIX
179
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
180
+ set (OpenMP_C_FLAGS
181
+ "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX} /include" )
182
+ set (OpenMP_CXX_FLAGS
183
+ "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX} /include" )
184
+ set (OpenMP_C_LIB_NAMES omp )
185
+ set (OpenMP_CXX_LIB_NAMES omp )
186
+ set (OpenMP_omp_LIBRARY ${HOMEBREW_LIBOMP_PREFIX} /lib/libomp.dylib )
187
+ find_package (OpenMP REQUIRED )
188
+ endif ()
189
+ else ()
190
+ find_package (OpenMP REQUIRED )
191
+ endif ()
176
192
endif (USE_OPENMP )
177
193
#Add for IBM i
178
194
if (${CMAKE_SYSTEM_NAME} MATCHES "OS400" )
Original file line number Diff line number Diff line change @@ -2709,8 +2709,15 @@ fi
2709
2709
2710
2710
if test ` uname -s` = " Darwin"
2711
2711
then
2712
- OPENMP_CXXFLAGS=' -Xclang -fopenmp'
2713
- OPENMP_LIB=' -lomp'
2712
+ if command -v brew & > /dev/null
2713
+ then
2714
+ HOMEBREW_LIBOMP_PREFIX=` brew --prefix libomp`
2715
+ else
2716
+ # Homebrew not found
2717
+ HOMEBREW_LIBOMP_PREFIX=' '
2718
+ fi
2719
+ OPENMP_CXXFLAGS=" -Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX} /include"
2720
+ OPENMP_LIB=" -lomp -L${HOMEBREW_LIBOMP_PREFIX} /lib"
2714
2721
ac_pkg_openmp=no
2715
2722
{ $as_echo " $as_me :${as_lineno-$LINENO } : checking whether OpenMP will work in a package" >&5
2716
2723
$as_echo_n " checking whether OpenMP will work in a package... " >&6 ; }
Original file line number Diff line number Diff line change 28
28
29
29
if test `uname -s` = "Darwin"
30
30
then
31
- OPENMP_CXXFLAGS='-Xclang -fopenmp'
32
- OPENMP_LIB='-lomp'
31
+ if command -v brew &> /dev/null
32
+ then
33
+ HOMEBREW_LIBOMP_PREFIX=`brew --prefix libomp`
34
+ else
35
+ # Homebrew not found
36
+ HOMEBREW_LIBOMP_PREFIX=''
37
+ fi
38
+ OPENMP_CXXFLAGS="-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include"
39
+ OPENMP_LIB="-lomp -L${HOMEBREW_LIBOMP_PREFIX}/lib"
33
40
ac_pkg_openmp=no
34
41
AC_MSG_CHECKING ( [ whether OpenMP will work in a package] )
35
42
AC_LANG_CONFTEST ( [ AC_LANG_PROGRAM ( [ [ #include <omp.h>] ] , [ [ return (omp_get_max_threads() <= 1); ] ] ) ] )
You can’t perform that action at this time.
0 commit comments