Enable OpenMP with Apple Clang (Mac default compiler) (#5146)

* Add OpenMP as CMake target

* Require CMake 3.12, to allow linking OpenMP target to objxgboost

* Specify OpenMP compiler flag for CUDA host compiler

* Require CMake 3.16+ if the OS is Mac OSX

* Use AppleClang in Mac tests.

* Update dmlc-core
This commit is contained in:
Philip Hyunsu Cho
2019-12-26 00:53:12 -08:00
committed by Jiaming Yuan
parent f3d7877802
commit 9b0af6e882
9 changed files with 34 additions and 45 deletions

View File

@@ -55,18 +55,12 @@ set_target_properties(
testxgboost PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON)
if ((NOT OpenMP_CXX_LIBRARIES) AND (NOT MSVC)) # old CMake doesn't define this variable
set(OpenMP_CXX_LIBRARIES "gomp;pthread")
endif ((NOT OpenMP_CXX_LIBRARIES) AND (NOT MSVC))
target_link_libraries(testxgboost
PRIVATE
${GTEST_LIBRARIES}
${LINKED_LIBRARIES_PRIVATE}
${OpenMP_CXX_LIBRARIES})
OpenMP::OpenMP_CXX)
target_compile_definitions(testxgboost PRIVATE ${XGBOOST_DEFINITIONS})
if (USE_OPENMP)
target_compile_options(testxgboost PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${OpenMP_CXX_FLAGS}>)
endif (USE_OPENMP)
set_output_directory(testxgboost ${xgboost_BINARY_DIR})
# This grouping organises source files nicely in visual studio