From a2a6cbbd1e535a7ce3b9936c92c47826ec99c094 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 28 Feb 2020 08:57:07 -0600 Subject: [PATCH] switched to cmake options --- CMakeLists.txt | 5 +++++ R-package/src/install.libs.R | 10 ++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 070b709c4160..bbf05da95229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ OPTION(USE_GPU "Enable GPU-accelerated training" OFF) OPTION(USE_SWIG "Enable SWIG to generate Java API" OFF) OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) OPTION(USE_R35 "Set to ON if your R version is not earlier than 3.5" OFF) +OPTION(BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) if(APPLE) OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF) @@ -68,6 +69,10 @@ if(USE_R35) ADD_DEFINITIONS(-DR_VER_ABOVE_35) endif(USE_R35) +if(BUILD_FOR_R) + ADD_DEFINITIONS(-DLGB_BUILD_R) +endif(BUILD_FOR_R) + if(USE_TIMETAG) ADD_DEFINITIONS(-DTIMETAG) endif(USE_TIMETAG) diff --git a/R-package/src/install.libs.R b/R-package/src/install.libs.R index 11f2150c2b53..59742860d973 100644 --- a/R-package/src/install.libs.R +++ b/R-package/src/install.libs.R @@ -43,6 +43,7 @@ if (!use_precompile) { if (R_ver >= 3.5) { cmake_cmd <- paste0(cmake_cmd, " -DUSE_R35=ON ") } + cmake_cmd <- paste0(cmake_cmd, " -DBUILD_FOR_R=ON ") # Check if Windows installation (for gcc vs Visual Studio) if (WINDOWS) { @@ -77,15 +78,8 @@ if (!use_precompile) { } } - # Add R CXXFLAGS. Do this in one command with ';' since R - # system() call isn't guaranteed to preserve environment from call to call - cmake_cmd <- paste0( - "export CXXFLAGS=\"${CXXFLAGS} -DLGB_R_BUILD\";" - , paste0(cmake_cmd, " ..") - ) - # Install - system(cmake_cmd) + system(paste0(cmake_cmd, " ..")) # R CMD check complains about the .NOTPARALLEL directive created in the cmake # Makefile. We don't need it here anyway since targets are built serially, so trying