Skip to content

Commit

Permalink
moved some changes out of this PR and into microsoft#2963
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Apr 15, 2020
1 parent bdf10e0 commit 88a7a09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
11 changes: 4 additions & 7 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
strategy:
maxParallel: 6
matrix:
r_package:
TASK: r-package
regular:
TASK: regular
sdist:
Expand All @@ -44,6 +42,8 @@ jobs:
TASK: gpu
METHOD: source
PYTHON_VERSION: 3.6
r_package:
TASK: r-package
steps:
- script: |
echo "##vso[task.setvariable variable=HOME_DIRECTORY]$AGENT_HOMEDIRECTORY"
Expand Down Expand Up @@ -78,8 +78,6 @@ jobs:
strategy:
maxParallel: 3
matrix:
r_package:
TASK: r-package
regular:
TASK: regular
PYTHON_VERSION: 3.7
Expand All @@ -88,6 +86,8 @@ jobs:
PYTHON_VERSION: 3.5
bdist:
TASK: bdist
r_package:
TASK: r-package
steps:
- script: |
echo "##vso[task.setvariable variable=HOME_DIRECTORY]$AGENT_HOMEDIRECTORY"
Expand Down Expand Up @@ -119,9 +119,6 @@ jobs:
strategy:
maxParallel: 3
matrix:
rpkg:
TASK: r-package
R_WINDOWS_VERSION: 3.6.3
regular:
TASK: regular
PYTHON_VERSION: 3.6
Expand Down
15 changes: 3 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ if(USE_SWIG)
COMMAND "${Java_JAR_EXECUTABLE}" -cf lightgbmlib.jar com)
else()
add_custom_command(TARGET _lightgbm_swig POST_BUILD
COMMAND "${Java_JAVAC_EXECUTABLE}" -d . java/*.java
COMMAND cp "${PROJECT_SOURCE_DIR}/*.so" com/microsoft/ml/lightgbm/linux/x86_64
COMMAND "${Java_JAR_EXECUTABLE}" -cf lightgbmlib.jar com)
COMMAND "${Java_JAVAC_EXECUTABLE}" -d . java/*.java
COMMAND cp "${PROJECT_SOURCE_DIR}/*.so" com/microsoft/ml/lightgbm/linux/x86_64
COMMAND "${Java_JAR_EXECUTABLE}" -cf lightgbmlib.jar com)
endif()
endif(USE_SWIG)

Expand Down Expand Up @@ -316,16 +316,7 @@ if(WIN32 AND (MINGW OR CYGWIN))
endif()

if(BUILD_FOR_R)
if(MSVC)
# https://docs.microsoft.com/en-us/cpp/build/reference/link-input-files?redirectedfrom=MSDN&view=vs-2019
set_property(
TARGET _lightgbm
PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL"
)
TARGET_LINK_LIBRARIES(_lightgbm ${CMAKE_CURRENT_BINARY_DIR}/R.lib)
else()
TARGET_LINK_LIBRARIES(_lightgbm ${LIBR_CORE_LIBRARY})
endif()
endif(BUILD_FOR_R)

install(TARGETS lightgbm _lightgbm
Expand Down
30 changes: 18 additions & 12 deletions R-package/src/cmake/modules/FindLibR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# LIBR_HOME
# LIBR_EXECUTABLE
# LIBR_INCLUDE_DIRS
# LIBR_LIB_DIR
# LIBR_CORE_LIBRARY
# and a CMake function to create R.lib for MSVC

Expand All @@ -35,8 +36,8 @@ function(create_rlib_for_msvc)
message(FATAL_ERROR "create_rlib_for_msvc() can only be used with MSVC")
endif()

if(NOT EXISTS "${LIBR_CORE_LIBRARY}")
message(FATAL_ERROR "LIBR_CORE_LIBRARY, '${LIBR_CORE_LIBRARY}', not found")
if(NOT EXISTS "${LIBR_LIB_DIR}")
message(FATAL_ERROR "LIBR_LIB_DIR, '${LIBR_LIB_DIR}', not found")
endif()

find_program(GENDEF_EXE gendef)
Expand All @@ -49,7 +50,7 @@ function(create_rlib_for_msvc)

# extract symbols from R.dll into R.def and R.lib import library
execute_process(COMMAND ${GENDEF_EXE}
"-" "${LIBR_CORE_LIBRARY}"
"-" "${LIBR_LIB_DIR}/R.dll"
OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/R.def"
)
execute_process(COMMAND ${DLLTOOL_EXE}
Expand Down Expand Up @@ -167,20 +168,24 @@ execute_process(
OUTPUT_VARIABLE LIBR_INCLUDE_DIRS
)

# ask R for the lib dir
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "--vanilla" "-e" "cat(normalizePath(R.home('lib'), winslash='/'))"
OUTPUT_VARIABLE LIBR_LIB_DIR
)

set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory")
set(LIBR_EXECUTABLE ${LIBR_EXECUTABLE} CACHE PATH "R executable")
set(LIBR_INCLUDE_DIRS ${LIBR_INCLUDE_DIRS} CACHE PATH "R include directory")
set(LIBR_LIB_DIR ${LIBR_LIB_DIR} CACHE PATH "R shared libraries directory")

# look for the core R library
if(WIN32)
set(LIBR_CORE_LIBRARY ${LIBR_HOME}/bin/${R_ARCH}/R.dll)
else()
find_library(
LIBR_CORE_LIBRARY
NAMES R
HINTS "${CMAKE_CURRENT_BINARY_DIR}" "${LIBR_HOME}/lib" "${LIBR_HOME}/bin/${R_ARCH}" "${LIBR_HOME}/bin" "${LIBR_LIBRARIES}"
)
endif()
find_library(
LIBR_CORE_LIBRARY
NAMES R R.dll
HINTS "${CMAKE_CURRENT_BINARY_DIR}" "${LIBR_HOME}/lib" "${LIBR_HOME}/bin/${R_ARCH}" "${LIBR_HOME}/bin" "${LIBR_LIBRARIES}"
PATHS "${LIBR_HOME}/bin/${R_ARCH}/R.dll"
)

set(LIBR_CORE_LIBRARY ${LIBR_CORE_LIBRARY} CACHE PATH "R core shared library")

Expand All @@ -200,5 +205,6 @@ find_package_handle_standard_args(LibR DEFAULT_MSG
LIBR_HOME
LIBR_EXECUTABLE
LIBR_INCLUDE_DIRS
LIBR_LIB_DIR
LIBR_CORE_LIBRARY
)

0 comments on commit 88a7a09

Please sign in to comment.