diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 5e99f9d36f45..a39dbc0e105b 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -24,8 +24,6 @@ jobs: strategy: maxParallel: 6 matrix: - r_package: - TASK: r-package regular: TASK: regular sdist: @@ -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" @@ -78,8 +78,6 @@ jobs: strategy: maxParallel: 3 matrix: - r_package: - TASK: r-package regular: TASK: regular PYTHON_VERSION: 3.7 @@ -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" @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ecd401831fc..ed09e3c03dd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 diff --git a/R-package/src/cmake/modules/FindLibR.cmake b/R-package/src/cmake/modules/FindLibR.cmake index 7d3e9cf499ab..307b23fa19d7 100644 --- a/R-package/src/cmake/modules/FindLibR.cmake +++ b/R-package/src/cmake/modules/FindLibR.cmake @@ -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 @@ -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) @@ -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} @@ -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") @@ -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 )