Skip to content

Commit 9b688ac

Browse files
authored
Fix mingw build with R. (#5918)
1 parent 8d77027 commit 9b688ac

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

cmake/modules/FindLibR.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# R_VERSION (for win)
1616
# R_ARCH (for win 64 when want 32 bit build)
1717
#
18-
# TODO:
19-
# - someone to verify OSX detection,
18+
# TODO:
19+
# - someone to verify OSX detection,
2020
# - possibly, add OSX detection based on current R in PATH or LIBR_EXECUTABLE
2121
# - improve registry-based R_HOME detection in Windows (from a set of R_VERSION's)
2222

@@ -37,8 +37,8 @@ endif()
3737
# Creates R.lib and R.def in the build directory for linking with MSVC
3838
function(create_rlib_for_msvc)
3939
# various checks and warnings
40-
if(NOT WIN32 OR NOT MSVC)
41-
message(FATAL_ERROR "create_rlib_for_msvc() can only be used with MSVC")
40+
if(NOT WIN32 OR (NOT MSVC AND NOT MINGW))
41+
message(FATAL_ERROR "create_rlib_for_msvc() can only be used with MSVC or MINGW")
4242
endif()
4343
if(NOT EXISTS "${LIBR_LIB_DIR}")
4444
message(FATAL_ERROR "LIBR_LIB_DIR was not set!")
@@ -90,15 +90,15 @@ if(APPLE)
9090
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory")
9191
set(LIBR_LIB_DIR "${LIBR_HOME}/lib" CACHE PATH "R lib directory")
9292
endif()
93-
93+
9494
# detection for UNIX & Win32
9595
else()
9696

9797
# attempt to find R executable
9898
if(NOT LIBR_EXECUTABLE)
9999
find_program(LIBR_EXECUTABLE NAMES R R.exe)
100100
endif()
101-
101+
102102
if(UNIX)
103103

104104
if(NOT LIBR_EXECUTABLE)
@@ -124,7 +124,7 @@ else()
124124

125125
# Windows
126126
else()
127-
# ask R for R_HOME
127+
# ask R for R_HOME
128128
if(LIBR_EXECUTABLE)
129129
execute_process(
130130
COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(normalizePath(R.home(),winslash='/'))"
@@ -147,7 +147,7 @@ else()
147147
# set other R paths based on home path
148148
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include")
149149
set(LIBR_LIB_DIR "${LIBR_HOME}/bin/${R_ARCH}")
150-
150+
151151
message(STATUS "LIBR_HOME [${LIBR_HOME}]")
152152
message(STATUS "LIBR_EXECUTABLE [${LIBR_EXECUTABLE}]")
153153
message(STATUS "LIBR_INCLUDE_DIRS [${LIBR_INCLUDE_DIRS}]")
@@ -158,7 +158,7 @@ message(STATUS "LIBR_CORE_LIBRARY [${LIBR_CORE_LIBRARY}]")
158158

159159
endif()
160160

161-
if(WIN32 AND MSVC)
161+
if((WIN32 AND MSVC) OR (WIN32 AND MINGW))
162162
# create a local R.lib import library for R.dll if it doesn't exist
163163
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/R.lib")
164164
create_rlib_for_msvc()

tests/cpp/predictor/test_gpu_predictor.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ TEST(GPUPredictor, ExternalMemoryTest) {
9494
gpu_predictor->Configure({});
9595

9696
LearnerModelParam param;
97-
param.num_feature = 2;
97+
param.num_feature = 5;
9898
const int n_classes = 3;
9999
param.num_output_group = n_classes;
100100
param.base_score = 0.5;

0 commit comments

Comments
 (0)