From 7aee0e51ed1ee3b08761cf6bd92f0ed3861a9cea Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Wed, 15 Jul 2020 20:22:11 -0700 Subject: [PATCH] Fix R package build with CMake 3.13 (#5895) * Fix R package build with CMake 3.13 * Require OpenMP for xgboost-r target --- R-package/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R-package/CMakeLists.txt b/R-package/CMakeLists.txt index ac60ff02e..d056ffe50 100644 --- a/R-package/CMakeLists.txt +++ b/R-package/CMakeLists.txt @@ -21,7 +21,11 @@ target_include_directories(xgboost-r ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/dmlc-core/include ${PROJECT_SOURCE_DIR}/rabit/include) -target_link_libraries(xgboost-r PRIVATE ${LIBR_CORE_LIBRARY}) +target_link_libraries(xgboost-r PUBLIC ${LIBR_CORE_LIBRARY}) +if (USE_OPENMP) + find_package(OpenMP REQUIRED) + target_link_libraries(xgboost-r PUBLIC OpenMP::OpenMP_CXX OpenMP::OpenMP_C) +endif (USE_OPENMP) set_target_properties( xgboost-r PROPERTIES CXX_STANDARD 14