diff --git a/.ci/setup.sh b/.ci/setup.sh index fe918d68a78c..53976e216815 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -29,6 +29,25 @@ if [[ $OS_NAME == "macos" ]]; then brew install swig fi else # Linux + if type -f apt 2>&1 > /dev/null; then + sudo apt-get update + sudo apt-get install --no-install-recommends -y \ + ca-certificates \ + curl + else + sudo yum update -y + sudo yum install -y \ + ca-certificates \ + curl + fi + CMAKE_VERSION="3.30.0" + curl -O -L \ + https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh \ + || exit 1 + sudo mkdir /opt/cmake || exit 1 + sudo sh cmake-${CMAKE_VERSION}-linux-${ARCH}.sh --skip-license --prefix=/opt/cmake || exit 1 + sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake || exit 1 + if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then # fixes error "unable to initialize frontend: Dialog" # https://github.com/moby/moby/issues/27988#issuecomment-462809153 @@ -40,9 +59,6 @@ else # Linux sudo apt-get install --no-install-recommends -y \ build-essential \ - ca-certificates \ - cmake \ - curl \ git \ libcurl4 \ libicu-dev \ @@ -117,21 +133,12 @@ else # Linux fi if [[ $TASK == "cuda" ]]; then echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections - apt-get update - apt-get install --no-install-recommends -y \ - curl \ - lsb-release \ - software-properties-common if [[ $COMPILER == "clang" ]]; then + apt-get update apt-get install --no-install-recommends -y \ clang \ libomp-dev fi - curl -sL https://apt.kitware.com/keys/kitware-archive-latest.asc | apt-key add - - apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" -y - apt-get update - apt-get install --no-install-recommends -y \ - cmake fi fi diff --git a/.ci/test-r-package-windows.ps1 b/.ci/test-r-package-windows.ps1 index 1b0405257583..8b17156749ea 100644 --- a/.ci/test-r-package-windows.ps1 +++ b/.ci/test-r-package-windows.ps1 @@ -45,6 +45,8 @@ Remove-From-Path ".*android.*" Remove-From-Path ".*Android.*" Remove-From-Path ".*chocolatey.*" Remove-From-Path ".*Chocolatey.*" +Remove-From-Path ".*cmake.*" +Remove-From-Path ".*CMake.*" Remove-From-Path ".*\\Git\\.*" Remove-From-Path "(?!.*pandoc.*).*hostedtoolcache.*" Remove-From-Path ".*Microsoft SDKs.*" @@ -87,10 +89,12 @@ if ($env:R_MAJOR_VERSION -eq "3") { Write-Output "[ERROR] Unrecognized R version: $env:R_VERSION" Check-Output $false } +$env:CMAKE_VERSION = "3.30.0" $env:R_LIB_PATH = "$env:BUILD_SOURCESDIRECTORY/RLibrary" -replace '[\\]', '/' $env:R_LIBS = "$env:R_LIB_PATH" -$env:PATH = "$env:RTOOLS_BIN;" + "$env:RTOOLS_MINGW_BIN;" + "$env:R_LIB_PATH/R/bin/x64;"+ $env:PATH +$env:CMAKE_PATH = "$env:BUILD_SOURCESDIRECTORY/CMake_installation" +$env:PATH = "$env:RTOOLS_BIN;" + "$env:RTOOLS_MINGW_BIN;" + "$env:R_LIB_PATH/R/bin/x64;" + "$env:CMAKE_PATH/cmake-$env:CMAKE_VERSION-windows-x86_64/bin;" + $env:PATH if ([version]$env:R_VERSION -lt [version]"4.0") { $env:CRAN_MIRROR = "https://cran-archive.r-project.org" } else { @@ -112,11 +116,13 @@ if (($env:COMPILER -eq "MINGW") -and ($env:R_BUILD_TYPE -eq "cmake")) { cd $env:BUILD_SOURCESDIRECTORY tzutil /s "GMT Standard Time" [Void][System.IO.Directory]::CreateDirectory($env:R_LIB_PATH) +[Void][System.IO.Directory]::CreateDirectory($env:CMAKE_PATH) -# download R and RTools -Write-Output "Downloading R and Rtools" +# download R, RTools and CMake +Write-Output "Downloading R, Rtools and CMake" Download-File-With-Retries -url "$env:CRAN_MIRROR/bin/windows/base/old/$env:R_WINDOWS_VERSION/R-$env:R_WINDOWS_VERSION-win.exe" -destfile "R-win.exe" Download-File-With-Retries -url "https://github.com/microsoft/LightGBM/releases/download/v2.0.12/$env:RTOOLS_EXE_FILE" -destfile "Rtools.exe" +Download-File-With-Retries -url "https://github.com/Kitware/CMake/releases/download/v$env:CMAKE_VERSION/cmake-$env:CMAKE_VERSION-windows-x86_64.zip" -destfile "$env:CMAKE_PATH/cmake.zip" # Install R Write-Output "Installing R" @@ -127,6 +133,13 @@ Write-Output "Installing Rtools" Start-Process -FilePath Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH" ; Check-Output $? Write-Output "Done installing Rtools" +Write-Output "Installing CMake" +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:CMAKE_PATH/cmake.zip", "$env:CMAKE_PATH") ; Check-Output $? +# Remove old CMake shiped with RTools +Remove-Item "$env:RTOOLS_MINGW_BIN/cmake.exe" -Force -ErrorAction Ignore +Write-Output "Done installing CMake" + Write-Output "Installing dependencies" $packages = "c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'processx', 'R6', 'RhpcBLASctl', 'testthat'), dependencies = c('Imports', 'Depends', 'LinkingTo')" Run-R-Code-Redirect-Stderr "options(install.packages.check.source = 'no'); install.packages($packages, repos = '$env:CRAN_MIRROR', type = 'binary', lib = '$env:R_LIB_PATH', Ncpus = parallel::detectCores())" ; Check-Output $? diff --git a/.ci/test-r-package.sh b/.ci/test-r-package.sh index a68e006e8036..5eba7669ad14 100755 --- a/.ci/test-r-package.sh +++ b/.ci/test-r-package.sh @@ -4,7 +4,6 @@ set -e -E -u -o pipefail # defaults ARCH=$(uname -m) -INSTALL_CMAKE_FROM_RELEASES=${INSTALL_CMAKE_FROM_RELEASES:-"false"} # set up R environment CRAN_MIRROR="https://cran.rstudio.com" @@ -74,15 +73,6 @@ if [[ $OS_NAME == "linux" ]]; then automake \ || exit 1 fi - if [[ $INSTALL_CMAKE_FROM_RELEASES == "true" ]]; then - curl -O -L \ - https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-${ARCH}.sh \ - || exit 1 - - sudo mkdir /opt/cmake || exit 1 - sudo sh cmake-3.25.1-linux-${ARCH}.sh --skip-license --prefix=/opt/cmake || exit 1 - sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake || exit 1 - fi fi # Installing R precompiled for Mac OS 10.11 or higher diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 735bcef4a0d7..6c32db1a2ed8 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -98,7 +98,7 @@ jobs: linux_version: "ubuntu20.04" task: cuda steps: - - name: Install latest git + - name: Install latest git and sudo run: | apt-get update apt-get install --no-install-recommends -y \ @@ -107,7 +107,8 @@ jobs: add-apt-repository ppa:git-core/ppa -y apt-get update apt-get install --no-install-recommends -y \ - git + git \ + sudo - name: Checkout repository uses: actions/checkout@v4 with: diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 0dcf30a27b30..1758583ad8e4 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -181,13 +181,13 @@ jobs: - name: Install pandoc uses: r-lib/actions/setup-pandoc@v2 if: matrix.container != 'ubuntu:18.04' - # R 3.6 binary isn't easily available on buntu 18.04, + # R 3.6 binary isn't easily available on Ubuntu 18.04, # but setup-pandoc>=2.7.1 is uses a too-new glibc for it. # ref: https://github.com/microsoft/LightGBM/issues/6298 - name: Install pandoc uses: r-lib/actions/setup-pandoc@v2.6.0 if: matrix.container == 'ubuntu:18.04' - - name: install tinytex + - name: Install tinytex if: startsWith(matrix.os, 'windows') uses: r-lib/actions/setup-tinytex@v2 env: @@ -204,11 +204,6 @@ jobs: elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then export OS_NAME="linux" export IN_UBUNTU_BASE_CONTAINER="true" - # the default version of cmake provided on Ubuntu 18.04 (v3.10.2), is not supported by LightGBM - # see https://github.com/microsoft/LightGBM/issues/5642 - if [[ "${{ matrix.container }}" == "ubuntu:18.04" ]]; then - export INSTALL_CMAKE_FROM_RELEASES="true" - fi fi export BUILD_DIRECTORY="$GITHUB_WORKSPACE" export R_VERSION="${{ matrix.r_version }}" diff --git a/CMakeLists.txt b/CMakeLists.txt index 982535b7258c..fb8daa9a104e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ option(__BUILD_FOR_PYTHON "Set to ON if building lib_lightgbm for use with the P option(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) option(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF) -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.28) # If using Visual Studio generators, always target v10.x of the Windows SDK. # Doing this avoids lookups that could fall back to very old versions, e.g. by finding diff --git a/cmake/IntegratedOpenCL.cmake b/cmake/IntegratedOpenCL.cmake index 32ddb51d674b..2397a7e7c26d 100644 --- a/cmake/IntegratedOpenCL.cmake +++ b/cmake/IntegratedOpenCL.cmake @@ -16,20 +16,26 @@ include(FetchContent) FetchContent_Declare(OpenCL-Headers GIT_REPOSITORY ${OPENCL_HEADER_REPOSITORY} GIT_TAG ${OPENCL_HEADER_TAG}) FetchContent_GetProperties(OpenCL-Headers) if(NOT OpenCL-Headers_POPULATED) - FetchContent_Populate(OpenCL-Headers) + FetchContent_MakeAvailable(OpenCL-Headers) message(STATUS "Populated OpenCL Headers") endif() set(OPENCL_ICD_LOADER_HEADERS_DIR ${opencl-headers_SOURCE_DIR} CACHE PATH "") # for OpenCL ICD Loader set(OpenCL_INCLUDE_DIR ${opencl-headers_SOURCE_DIR} CACHE PATH "") # for Boost::Compute -FetchContent_Declare(OpenCL-ICD-Loader GIT_REPOSITORY ${OPENCL_LOADER_REPOSITORY} GIT_TAG ${OPENCL_LOADER_TAG}) +FetchContent_Declare( + OpenCL-ICD-Loader + GIT_REPOSITORY + ${OPENCL_LOADER_REPOSITORY} + GIT_TAG + ${OPENCL_LOADER_TAG} + EXCLUDE_FROM_ALL +) FetchContent_GetProperties(OpenCL-ICD-Loader) if(NOT OpenCL-ICD-Loader_POPULATED) - FetchContent_Populate(OpenCL-ICD-Loader) + FetchContent_MakeAvailable(OpenCL-ICD-Loader) if(WIN32) set(USE_DYNAMIC_VCXX_RUNTIME ON) endif() - add_subdirectory(${opencl-icd-loader_SOURCE_DIR} ${opencl-icd-loader_BINARY_DIR} EXCLUDE_FROM_ALL) message(STATUS "Populated OpenCL ICD Loader") endif() list(APPEND INTEGRATED_OPENCL_INCLUDES ${OPENCL_ICD_LOADER_HEADERS_DIR}) diff --git a/python-package/pyproject.toml b/python-package/pyproject.toml index 41bfd202fbc3..3ff4a3d2c1fe 100644 --- a/python-package/pyproject.toml +++ b/python-package/pyproject.toml @@ -63,7 +63,7 @@ build-backend = "scikit_build_core.build" # based on https://github.com/scikit-build/scikit-build-core#configuration [tool.scikit-build] -cmake.version = ">=3.18" +cmake.version = ">=3.28" ninja.version = ">=1.11" ninja.make-fallback = true cmake.args = [