Skip to content

Commit

Permalink
Patch libxgboost4j.dylib too
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Jun 18, 2024
1 parent 3b179a2 commit 8227f63
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ endif()

find_package(Threads REQUIRED)

# -- OpenMP
include(cmake/FindOpenMPMacOS.cmake)
if(USE_OPENMP)
if(APPLE)
include(cmake/FindOpenMPMacOS.cmake)
find_openmp_macos()
else()
find_package(OpenMP REQUIRED)
endif()
endif()
#Add for IBM i

# Add for IBM i
if(${CMAKE_SYSTEM_NAME} MATCHES "OS400")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -X64 qc <TARGET> <OBJECTS>")
Expand Down Expand Up @@ -369,9 +371,6 @@ endif()

if(USE_OPENMP AND APPLE)
patch_openmp_path_macos(xgboost libxgboost)
if(JVM_BINDINGS)
patch_openmp_path_macos(xgboost4j libxgboost4j)
endif()
endif()

if(KEEP_BUILD_ARTIFACTS_IN_BINARY_DIR)
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindOpenMPMacOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function(patch_openmp_path_macos target target_default_output_name)
)
endif()

message(STATUS "Creating shared lib: ${__LIBXGBOOST_FILENAME_${target}}")
message(STATUS "Creating shared lib for target ${target}: ${__LIBXGBOOST_FILENAME_${target}}")

# Override the absolute path to OpenMP with a relative one using @rpath.
#
Expand Down
5 changes: 5 additions & 0 deletions jvm-packages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ target_include_directories(xgboost4j
${PROJECT_SOURCE_DIR}/dmlc-core/include)

set_output_directory(xgboost4j ${PROJECT_SOURCE_DIR}/lib)

# MacOS: Patch libxgboost4j.dylib to use @rpath/libomp.dylib
if(USE_OPENMP AND APPLE)
patch_openmp_path_macos(xgboost4j libxgboost4j)
endif()

0 comments on commit 8227f63

Please sign in to comment.