Skip to content

Commit

Permalink
removed some duplication in cmake scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Mar 17, 2020
1 parent fe136d9 commit 73eafe5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ endif(USE_R35)

if(BUILD_FOR_R)
list(APPEND CMAKE_MODULE_PATH "${lightgbm_SOURCE_DIR}/cmake/modules")
set(CMAKE_R_VERSION ${CMAKE_R_VERSION})
message(STATUS "Passed-in R version: " ${CMAKE_R_VERSION})
find_package(LibR REQUIRED)
message(STATUS "LIBR_CORE_LIBRARY: " ${LIBR_CORE_LIBRARY})
message(STATUS "LIBR_INCLUDE_DIRS " ${LIBR_INCLUDE_DIRS})
message(STATUS "LIBR_HOME [${LIBR_HOME}]")
message(STATUS "LIBR_EXECUTABLE [${LIBR_EXECUTABLE}]")
message(STATUS "LIBR_INCLUDE_DIRS [${LIBR_INCLUDE_DIRS}]")
message(STATUS "LIBR_LIB_DIR [${LIBR_LIB_DIR}]")
message(STATUS "LIBR_CORE_LIBRARY [${LIBR_CORE_LIBRARY}]")
include_directories(${LIBR_INCLUDE_DIRS})
ADD_DEFINITIONS(-DLGB_R_BUILD)
endif(BUILD_FOR_R)
Expand Down
15 changes: 4 additions & 11 deletions R-package/src/cmake/modules/FindLibR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ if(APPLE)
COMMAND ${LIBR_EXECUTABLE} "--slave" "--vanilla" "-e" "cat(R.home())"
OUTPUT_VARIABLE LIBR_HOME
)
set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory")
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory")
set(LIBR_LIB_DIR "${LIBR_HOME}/lib" CACHE PATH "R lib directory")
set(LIBR_HOME ${LIBR_HOME})
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include")
set(LIBR_LIB_DIR "${LIBR_HOME}/lib")
endif()

# detection for UNIX & Win32
Expand All @@ -100,7 +100,7 @@ else()
find_program(
LIBR_EXECUTABLE
NO_DEFAULT_PATH
HINTS "${CMAKE_CURRENT_BINARY_DIR}" "/usr/bin" "/usr/lib/"
HINTS "${CMAKE_CURRENT_BINARY_DIR}" "/usr/bin" "/usr/lib/" "/usr/local/bin/"
NAMES R R.exe
)

Expand Down Expand Up @@ -180,12 +180,6 @@ else()
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}]")
message(STATUS "LIBR_LIB_DIR [${LIBR_LIB_DIR}]")
message(STATUS "LIBR_CORE_LIBRARY [${LIBR_CORE_LIBRARY}]")

endif()

endif()
Expand Down Expand Up @@ -221,7 +215,6 @@ find_package_handle_standard_args(LibR DEFAULT_MSG
LIBR_EXECUTABLE
LIBR_INCLUDE_DIRS
LIBR_LIB_DIR
LIBR_CORE_LIBRARY
)

if(LIBR_FOUND)
Expand Down

0 comments on commit 73eafe5

Please sign in to comment.