Skip to content

Commit

Permalink
switched to cmake options
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Feb 28, 2020
1 parent b88e963 commit a2a6cbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a2a6cbb

Please sign in to comment.