From 1f19a75dd90990f7211f146fa2e493b8f618fb81 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 7 Apr 2024 20:40:27 -0500 Subject: [PATCH 1/3] [c++] remove uses of '..' in headers --- CMakeLists.txt | 19 ++++++++++++++++++- build-cran-package.sh | 6 +++--- include/LightGBM/utils/common.h | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ff289b9d045..96efb8ca7f74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,12 @@ include_directories(${EIGEN_DIR}) add_definitions(-DEIGEN_MPL2_ONLY) add_definitions(-DEIGEN_DONT_PARALLELIZE) +set(FAST_DOUBLE_PARSER_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/external_libs/fast_double_parser/include") +include_directories(${FAST_DOUBLE_PARSER_INCLUDE_DIR}) + +set(FMT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/external_libs/fmt/include") +include_directories(${FMT_INCLUDE_DIR}) + if(__BUILD_FOR_R) find_package(LibR REQUIRED) message(STATUS "LIBR_EXECUTABLE: ${LIBR_EXECUTABLE}") @@ -703,5 +709,16 @@ install( ) if(INSTALL_HEADERS) - install(DIRECTORY ${LightGBM_HEADER_DIR}/LightGBM DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + install( + DIRECTORY ${LightGBM_HEADER_DIR}/LightGBM + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + ) + install( + DIRECTORY ${FAST_DOUBLE_PARSER_INCLUDE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/external_libs + ) + install( + DIRECTORY ${FMT_INCLUDE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/external_libs + ) endif() diff --git a/build-cran-package.sh b/build-cran-package.sh index 7ce5ab494638..b106a5b5523e 100755 --- a/build-cran-package.sh +++ b/build-cran-package.sh @@ -76,12 +76,12 @@ fi cp \ external_libs/fast_double_parser/include/fast_double_parser.h \ - "${TEMP_R_DIR}/src/include/LightGBM" + "${TEMP_R_DIR}/src/include/" -mkdir -p "${TEMP_R_DIR}/src/include/LightGBM/fmt" +mkdir -p "${TEMP_R_DIR}/src/include/fmt" cp \ external_libs/fmt/include/fmt/*.h \ - "${TEMP_R_DIR}/src/include/LightGBM/fmt/" + "${TEMP_R_DIR}/src/include/fmt/" # including only specific files from Eigen, to keep the R package # small and avoid redistributing code with licenses incompatible with diff --git a/include/LightGBM/utils/common.h b/include/LightGBM/utils/common.h index f38375fb7370..6c3ebf5d0096 100644 --- a/include/LightGBM/utils/common.h +++ b/include/LightGBM/utils/common.h @@ -30,8 +30,8 @@ #include #define FMT_HEADER_ONLY -#include "../../../external_libs/fast_double_parser/include/fast_double_parser.h" -#include "../../../external_libs/fmt/include/fmt/format.h" +#include "fast_double_parser.h" +#include "fmt/format.h" #ifdef _MSC_VER #include From b807bdb3fc25a8e895d13af4ea41130efd8fe1d0 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 7 Apr 2024 21:37:25 -0500 Subject: [PATCH 2/3] update install path --- CMakeLists.txt | 9 +++++---- build-cran-package.sh | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96efb8ca7f74..d1655ea2cb6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -714,11 +714,12 @@ if(INSTALL_HEADERS) DESTINATION ${CMAKE_INSTALL_PREFIX}/include ) install( - DIRECTORY ${FAST_DOUBLE_PARSER_INCLUDE_DIR} - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/external_libs + FILES ${FAST_DOUBLE_PARSER_INCLUDE_DIR}/fast_double_parser.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/LightGBM/utils ) install( - DIRECTORY ${FMT_INCLUDE_DIR} - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/external_libs + DIRECTORY ${FMT_INCLUDE_DIR}/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/LightGBM/utils + FILES_MATCHING PATTERN "*.h" ) endif() diff --git a/build-cran-package.sh b/build-cran-package.sh index b106a5b5523e..232b95d6d652 100755 --- a/build-cran-package.sh +++ b/build-cran-package.sh @@ -76,12 +76,12 @@ fi cp \ external_libs/fast_double_parser/include/fast_double_parser.h \ - "${TEMP_R_DIR}/src/include/" + "${TEMP_R_DIR}/src/include/LightGBM/utils" -mkdir -p "${TEMP_R_DIR}/src/include/fmt" +mkdir -p "${TEMP_R_DIR}/src/include/LightGBM/utils/fmt" cp \ external_libs/fmt/include/fmt/*.h \ - "${TEMP_R_DIR}/src/include/fmt/" + "${TEMP_R_DIR}/src/include/LightGBM/utils/fmt" # including only specific files from Eigen, to keep the R package # small and avoid redistributing code with licenses incompatible with From 02ae45951dc94faf65891cf588ae96dda3b5a34c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 30 Apr 2024 21:32:59 -0500 Subject: [PATCH 3/3] remove build-cran-packageg logic --- build-cran-package.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/build-cran-package.sh b/build-cran-package.sh index f2f50fa8c4bd..aafe243994c6 100755 --- a/build-cran-package.sh +++ b/build-cran-package.sh @@ -155,16 +155,6 @@ cd "${TEMP_R_DIR}" done find . -name '*.h.bak' -o -name '*.hpp.bak' -o -name '*.cpp.bak' -exec rm {} \; - sed \ - -i.bak \ - -e 's/\.\..*fmt\/format\.h/LightGBM\/fmt\/format\.h/' \ - src/include/LightGBM/utils/common.h - - sed \ - -i.bak \ - -e 's/\.\..*fast_double_parser\.h/LightGBM\/fast_double_parser\.h/' \ - src/include/LightGBM/utils/common.h - # When building an R package with 'configure', it seems # you're guaranteed to get a shared library called # .so/dll/dylib. The package source code expects