From 945fffa5a7b8830e31d667ad58142d4947ad0cc1 Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Fri, 19 Mar 2021 21:36:05 +0300 Subject: [PATCH] store all CMake files in one place --- CMakeLists.txt | 7 +++---- build-cran-package.sh | 1 - build_r.R | 8 ++++++++ .../IntegratedOpenCL.cmake | 0 {R-package/src/cmake => cmake}/modules/FindLibR.cmake | 0 python-package/MANIFEST.in | 2 +- python-package/setup.py | 6 ++++-- 7 files changed, 16 insertions(+), 8 deletions(-) rename CMakeIntegratedOpenCL.cmake => cmake/IntegratedOpenCL.cmake (100%) rename {R-package/src/cmake => cmake}/modules/FindLibR.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c8ce6877a07..b845f36244d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,6 @@ include_directories(${EIGEN_DIR}) ADD_DEFINITIONS(-DEIGEN_MPL2_ONLY) if(__BUILD_FOR_R) - list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") find_package(LibR REQUIRED) message(STATUS "LIBR_EXECUTABLE: ${LIBR_EXECUTABLE}") message(STATUS "LIBR_INCLUDE_DIRS: ${LIBR_INCLUDE_DIRS}") @@ -157,7 +156,7 @@ endif(USE_GPU) if(__INTEGRATE_OPENCL) if(WIN32) - include(CMakeIntegratedOpenCL.cmake) + include(cmake/IntegratedOpenCL.cmake) ADD_DEFINITIONS(-DUSE_GPU) else() message(FATAL_ERROR "Integrated OpenCL build is available only for Windows") @@ -418,10 +417,10 @@ if(USE_GPU) endif(USE_GPU) if(__INTEGRATE_OPENCL) - # targets OpenCL and Boost are added in CMakeIntegratedOpenCL.cmake + # targets OpenCL and Boost are added in IntegratedOpenCL.cmake add_dependencies(lightgbm OpenCL Boost) add_dependencies(_lightgbm OpenCL Boost) - # variables INTEGRATED_OPENCL_* are set in CMakeIntegratedOpenCL.cmake + # variables INTEGRATED_OPENCL_* are set in IntegratedOpenCL.cmake target_include_directories(lightgbm PRIVATE ${INTEGRATED_OPENCL_INCLUDES}) target_include_directories(_lightgbm PRIVATE ${INTEGRATED_OPENCL_INCLUDES}) target_compile_definitions(lightgbm PRIVATE ${INTEGRATED_OPENCL_DEFINITIONS}) diff --git a/build-cran-package.sh b/build-cran-package.sh index 72e61f7c1c9f..318b96fde22e 100755 --- a/build-cran-package.sh +++ b/build-cran-package.sh @@ -63,7 +63,6 @@ cd ${TEMP_R_DIR} # Remove files not needed for CRAN echo "Removing files not needed for CRAN" rm src/install.libs.R - rm -r src/cmake/ rm -r inst/ rm -r pkgdown/ rm cran-comments.md diff --git a/build_r.R b/build_r.R index d96447c2e604..a4eeee228c6b 100644 --- a/build_r.R +++ b/build_r.R @@ -316,6 +316,14 @@ for (submodule in list.dirs( } # copy files into the place CMake expects +CMAKE_MODULES_R_DIR <- file.path(TEMP_SOURCE_DIR, "cmake", "modules") +dir.create(CMAKE_MODULES_R_DIR, recursive = TRUE) +result <- file.copy( + from = file.path("cmake", "modules", "FindLibR.cmake") + , to = sprintf("%s/", CMAKE_MODULES_R_DIR) + , overwrite = TRUE +) +.handle_result(result) for (src_file in c("lightgbm_R.cpp", "lightgbm_R.h", "R_object_helper.h")) { result <- file.copy( from = file.path(TEMP_SOURCE_DIR, src_file) diff --git a/CMakeIntegratedOpenCL.cmake b/cmake/IntegratedOpenCL.cmake similarity index 100% rename from CMakeIntegratedOpenCL.cmake rename to cmake/IntegratedOpenCL.cmake diff --git a/R-package/src/cmake/modules/FindLibR.cmake b/cmake/modules/FindLibR.cmake similarity index 100% rename from R-package/src/cmake/modules/FindLibR.cmake rename to cmake/modules/FindLibR.cmake diff --git a/python-package/MANIFEST.in b/python-package/MANIFEST.in index 7fad0fa42e82..7973e2f49f13 100644 --- a/python-package/MANIFEST.in +++ b/python-package/MANIFEST.in @@ -3,7 +3,7 @@ include LICENSE include *.rst *.txt recursive-include lightgbm VERSION.txt *.py *.so include compile/CMakeLists.txt -include compile/CMakeIntegratedOpenCL.cmake +include compile/cmake/IntegratedOpenCL.cmake recursive-include compile *.so recursive-include compile/Release *.dll include compile/external_libs/compute/CMakeLists.txt diff --git a/python-package/setup.py b/python-package/setup.py index de62a89ef55b..2a4c99588d42 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -83,8 +83,10 @@ def copy_files_helper(folder_name): os.path.join(CURRENT_DIR, "compile", "CMakeLists.txt"), verbose=0) if integrated_opencl: - copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "CMakeIntegratedOpenCL.cmake"), - os.path.join(CURRENT_DIR, "compile", "CMakeIntegratedOpenCL.cmake"), + if not os.path.exists(os.path.join(CURRENT_DIR, "compile", "cmake")): + os.makedirs(os.path.join(CURRENT_DIR, "compile", "cmake")) + copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "cmake", "IntegratedOpenCL.cmake"), + os.path.join(CURRENT_DIR, "compile", "cmake", "IntegratedOpenCL.cmake"), verbose=0)