From b13122718bab4fc3d445910d31fb9a7c0beab042 Mon Sep 17 00:00:00 2001 From: fis Date: Tue, 21 Jul 2020 13:56:11 +0800 Subject: [PATCH] Fix mingw build with R. --- .github/workflows/main.yml | 2 +- cmake/modules/FindLibR.cmake | 18 +++++++++--------- tests/cpp/predictor/test_gpu_predictor.cu | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 760a2810823c..5d09633f8fd8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ # This is a basic workflow to help you get started with Actions -name: XGoost-CI +name: XGBoost-CI # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch diff --git a/cmake/modules/FindLibR.cmake b/cmake/modules/FindLibR.cmake index a775feb28550..c9d9509fadf5 100644 --- a/cmake/modules/FindLibR.cmake +++ b/cmake/modules/FindLibR.cmake @@ -15,8 +15,8 @@ # R_VERSION (for win) # R_ARCH (for win 64 when want 32 bit build) # -# TODO: -# - someone to verify OSX detection, +# TODO: +# - someone to verify OSX detection, # - possibly, add OSX detection based on current R in PATH or LIBR_EXECUTABLE # - improve registry-based R_HOME detection in Windows (from a set of R_VERSION's) @@ -37,8 +37,8 @@ endif() # Creates R.lib and R.def in the build directory for linking with MSVC function(create_rlib_for_msvc) # various checks and warnings - if(NOT WIN32 OR NOT MSVC) - message(FATAL_ERROR "create_rlib_for_msvc() can only be used with MSVC") + if(NOT WIN32 OR (NOT MSVC AND NOT MINGW)) + message(FATAL_ERROR "create_rlib_for_msvc() can only be used with MSVC or MINGW") endif() if(NOT EXISTS "${LIBR_LIB_DIR}") message(FATAL_ERROR "LIBR_LIB_DIR was not set!") @@ -90,7 +90,7 @@ if(APPLE) set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory") set(LIBR_LIB_DIR "${LIBR_HOME}/lib" CACHE PATH "R lib directory") endif() - + # detection for UNIX & Win32 else() @@ -98,7 +98,7 @@ else() if(NOT LIBR_EXECUTABLE) find_program(LIBR_EXECUTABLE NAMES R R.exe) endif() - + if(UNIX) if(NOT LIBR_EXECUTABLE) @@ -124,7 +124,7 @@ else() # Windows else() - # ask R for R_HOME + # ask R for R_HOME if(LIBR_EXECUTABLE) execute_process( COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(normalizePath(R.home(),winslash='/'))" @@ -147,7 +147,7 @@ else() # set other R paths based on home path set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include") set(LIBR_LIB_DIR "${LIBR_HOME}/bin/${R_ARCH}") - + message(STATUS "LIBR_HOME [${LIBR_HOME}]") message(STATUS "LIBR_EXECUTABLE [${LIBR_EXECUTABLE}]") message(STATUS "LIBR_INCLUDE_DIRS [${LIBR_INCLUDE_DIRS}]") @@ -158,7 +158,7 @@ message(STATUS "LIBR_CORE_LIBRARY [${LIBR_CORE_LIBRARY}]") endif() -if(WIN32 AND MSVC) +if((WIN32 AND MSVC) OR (WIN32 AND MINGW)) # create a local R.lib import library for R.dll if it doesn't exist if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/R.lib") create_rlib_for_msvc() diff --git a/tests/cpp/predictor/test_gpu_predictor.cu b/tests/cpp/predictor/test_gpu_predictor.cu index fc40d1778b84..f6fd3d7f0d53 100644 --- a/tests/cpp/predictor/test_gpu_predictor.cu +++ b/tests/cpp/predictor/test_gpu_predictor.cu @@ -94,7 +94,7 @@ TEST(GPUPredictor, ExternalMemoryTest) { gpu_predictor->Configure({}); LearnerModelParam param; - param.num_feature = 2; + param.num_feature = 5; const int n_classes = 3; param.num_output_group = n_classes; param.base_score = 0.5;