Unverified Commit 3175a912 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[ci] Require CMake 3.28 and replace `FetchContent_Populate` with...

[ci] Require CMake 3.28 and replace `FetchContent_Populate` with `FetchContent_MakeAvailable` (#6550)

* Replace `FetchContent_Populate` with `FetchContent_MakeAvailable`

* Test with VS 2022

* Update IntegratedOpenCL.cmake

* Update IntegratedOpenCL.cmake

* Update IntegratedOpenCL.cmake

* Update IntegratedOpenCL.cmake

* Update IntegratedOpenCL.cmake

* Update .vsts-ci.yml

* bump minimum CMake version

* force symlinking

* fix line length

* install curl

* install sudo

* install certs

* install CMake for R Windows jobs

* debug cmake

* new try

* remove CMake from RTools

* cleanup

* remove duplicted curl installation

* CMake version as variable
parent 29b48f61
...@@ -29,6 +29,25 @@ if [[ $OS_NAME == "macos" ]]; then ...@@ -29,6 +29,25 @@ if [[ $OS_NAME == "macos" ]]; then
brew install swig brew install swig
fi fi
else # Linux 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 if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
# fixes error "unable to initialize frontend: Dialog" # fixes error "unable to initialize frontend: Dialog"
# https://github.com/moby/moby/issues/27988#issuecomment-462809153 # https://github.com/moby/moby/issues/27988#issuecomment-462809153
...@@ -40,9 +59,6 @@ else # Linux ...@@ -40,9 +59,6 @@ else # Linux
sudo apt-get install --no-install-recommends -y \ sudo apt-get install --no-install-recommends -y \
build-essential \ build-essential \
ca-certificates \
cmake \
curl \
git \ git \
libcurl4 \ libcurl4 \
libicu-dev \ libicu-dev \
...@@ -117,21 +133,12 @@ else # Linux ...@@ -117,21 +133,12 @@ else # Linux
fi fi
if [[ $TASK == "cuda" ]]; then if [[ $TASK == "cuda" ]]; then
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections 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 if [[ $COMPILER == "clang" ]]; then
apt-get update
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
clang \ clang \
libomp-dev libomp-dev
fi 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
fi fi
......
...@@ -45,6 +45,8 @@ Remove-From-Path ".*android.*" ...@@ -45,6 +45,8 @@ Remove-From-Path ".*android.*"
Remove-From-Path ".*Android.*" Remove-From-Path ".*Android.*"
Remove-From-Path ".*chocolatey.*" Remove-From-Path ".*chocolatey.*"
Remove-From-Path ".*Chocolatey.*" Remove-From-Path ".*Chocolatey.*"
Remove-From-Path ".*cmake.*"
Remove-From-Path ".*CMake.*"
Remove-From-Path ".*\\Git\\.*" Remove-From-Path ".*\\Git\\.*"
Remove-From-Path "(?!.*pandoc.*).*hostedtoolcache.*" Remove-From-Path "(?!.*pandoc.*).*hostedtoolcache.*"
Remove-From-Path ".*Microsoft SDKs.*" Remove-From-Path ".*Microsoft SDKs.*"
...@@ -87,10 +89,12 @@ if ($env:R_MAJOR_VERSION -eq "3") { ...@@ -87,10 +89,12 @@ if ($env:R_MAJOR_VERSION -eq "3") {
Write-Output "[ERROR] Unrecognized R version: $env:R_VERSION" Write-Output "[ERROR] Unrecognized R version: $env:R_VERSION"
Check-Output $false Check-Output $false
} }
$env:CMAKE_VERSION = "3.30.0"
$env:R_LIB_PATH = "$env:BUILD_SOURCESDIRECTORY/RLibrary" -replace '[\\]', '/' $env:R_LIB_PATH = "$env:BUILD_SOURCESDIRECTORY/RLibrary" -replace '[\\]', '/'
$env:R_LIBS = "$env:R_LIB_PATH" $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") { if ([version]$env:R_VERSION -lt [version]"4.0") {
$env:CRAN_MIRROR = "https://cran-archive.r-project.org" $env:CRAN_MIRROR = "https://cran-archive.r-project.org"
} else { } else {
...@@ -112,11 +116,13 @@ if (($env:COMPILER -eq "MINGW") -and ($env:R_BUILD_TYPE -eq "cmake")) { ...@@ -112,11 +116,13 @@ if (($env:COMPILER -eq "MINGW") -and ($env:R_BUILD_TYPE -eq "cmake")) {
cd $env:BUILD_SOURCESDIRECTORY cd $env:BUILD_SOURCESDIRECTORY
tzutil /s "GMT Standard Time" tzutil /s "GMT Standard Time"
[Void][System.IO.Directory]::CreateDirectory($env:R_LIB_PATH) [Void][System.IO.Directory]::CreateDirectory($env:R_LIB_PATH)
[Void][System.IO.Directory]::CreateDirectory($env:CMAKE_PATH)
# download R and RTools # download R, RTools and CMake
Write-Output "Downloading R and Rtools" 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 "$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/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 # Install R
Write-Output "Installing R" Write-Output "Installing R"
...@@ -127,6 +133,13 @@ Write-Output "Installing Rtools" ...@@ -127,6 +133,13 @@ Write-Output "Installing Rtools"
Start-Process -FilePath Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH" ; Check-Output $? Start-Process -FilePath Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH" ; Check-Output $?
Write-Output "Done installing Rtools" 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" Write-Output "Installing dependencies"
$packages = "c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'processx', 'R6', 'RhpcBLASctl', 'testthat'), dependencies = c('Imports', 'Depends', 'LinkingTo')" $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 $? 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 $?
......
...@@ -4,7 +4,6 @@ set -e -E -u -o pipefail ...@@ -4,7 +4,6 @@ set -e -E -u -o pipefail
# defaults # defaults
ARCH=$(uname -m) ARCH=$(uname -m)
INSTALL_CMAKE_FROM_RELEASES=${INSTALL_CMAKE_FROM_RELEASES:-"false"}
# set up R environment # set up R environment
CRAN_MIRROR="https://cran.rstudio.com" CRAN_MIRROR="https://cran.rstudio.com"
...@@ -74,15 +73,6 @@ if [[ $OS_NAME == "linux" ]]; then ...@@ -74,15 +73,6 @@ if [[ $OS_NAME == "linux" ]]; then
automake \ automake \
|| exit 1 || exit 1
fi 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 fi
# Installing R precompiled for Mac OS 10.11 or higher # Installing R precompiled for Mac OS 10.11 or higher
......
...@@ -98,7 +98,7 @@ jobs: ...@@ -98,7 +98,7 @@ jobs:
linux_version: "ubuntu20.04" linux_version: "ubuntu20.04"
task: cuda task: cuda
steps: steps:
- name: Install latest git - name: Install latest git and sudo
run: | run: |
apt-get update apt-get update
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
...@@ -107,7 +107,8 @@ jobs: ...@@ -107,7 +107,8 @@ jobs:
add-apt-repository ppa:git-core/ppa -y add-apt-repository ppa:git-core/ppa -y
apt-get update apt-get update
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
git git \
sudo
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
......
...@@ -181,13 +181,13 @@ jobs: ...@@ -181,13 +181,13 @@ jobs:
- name: Install pandoc - name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2 uses: r-lib/actions/setup-pandoc@v2
if: matrix.container != 'ubuntu:18.04' 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. # but setup-pandoc>=2.7.1 is uses a too-new glibc for it.
# ref: https://github.com/microsoft/LightGBM/issues/6298 # ref: https://github.com/microsoft/LightGBM/issues/6298
- name: Install pandoc - name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2.6.0 uses: r-lib/actions/setup-pandoc@v2.6.0
if: matrix.container == 'ubuntu:18.04' if: matrix.container == 'ubuntu:18.04'
- name: install tinytex - name: Install tinytex
if: startsWith(matrix.os, 'windows') if: startsWith(matrix.os, 'windows')
uses: r-lib/actions/setup-tinytex@v2 uses: r-lib/actions/setup-tinytex@v2
env: env:
...@@ -204,11 +204,6 @@ jobs: ...@@ -204,11 +204,6 @@ jobs:
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
export OS_NAME="linux" export OS_NAME="linux"
export IN_UBUNTU_BASE_CONTAINER="true" 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 fi
export BUILD_DIRECTORY="$GITHUB_WORKSPACE" export BUILD_DIRECTORY="$GITHUB_WORKSPACE"
export R_VERSION="${{ matrix.r_version }}" export R_VERSION="${{ matrix.r_version }}"
......
...@@ -23,7 +23,7 @@ option(__BUILD_FOR_PYTHON "Set to ON if building lib_lightgbm for use with the P ...@@ -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(__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) 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. # 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 # Doing this avoids lookups that could fall back to very old versions, e.g. by finding
......
...@@ -16,20 +16,26 @@ include(FetchContent) ...@@ -16,20 +16,26 @@ include(FetchContent)
FetchContent_Declare(OpenCL-Headers GIT_REPOSITORY ${OPENCL_HEADER_REPOSITORY} GIT_TAG ${OPENCL_HEADER_TAG}) FetchContent_Declare(OpenCL-Headers GIT_REPOSITORY ${OPENCL_HEADER_REPOSITORY} GIT_TAG ${OPENCL_HEADER_TAG})
FetchContent_GetProperties(OpenCL-Headers) FetchContent_GetProperties(OpenCL-Headers)
if(NOT OpenCL-Headers_POPULATED) if(NOT OpenCL-Headers_POPULATED)
FetchContent_Populate(OpenCL-Headers) FetchContent_MakeAvailable(OpenCL-Headers)
message(STATUS "Populated OpenCL Headers") message(STATUS "Populated OpenCL Headers")
endif() endif()
set(OPENCL_ICD_LOADER_HEADERS_DIR ${opencl-headers_SOURCE_DIR} CACHE PATH "") # for OpenCL ICD Loader 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 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) FetchContent_GetProperties(OpenCL-ICD-Loader)
if(NOT OpenCL-ICD-Loader_POPULATED) if(NOT OpenCL-ICD-Loader_POPULATED)
FetchContent_Populate(OpenCL-ICD-Loader) FetchContent_MakeAvailable(OpenCL-ICD-Loader)
if(WIN32) if(WIN32)
set(USE_DYNAMIC_VCXX_RUNTIME ON) set(USE_DYNAMIC_VCXX_RUNTIME ON)
endif() endif()
add_subdirectory(${opencl-icd-loader_SOURCE_DIR} ${opencl-icd-loader_BINARY_DIR} EXCLUDE_FROM_ALL)
message(STATUS "Populated OpenCL ICD Loader") message(STATUS "Populated OpenCL ICD Loader")
endif() endif()
list(APPEND INTEGRATED_OPENCL_INCLUDES ${OPENCL_ICD_LOADER_HEADERS_DIR}) list(APPEND INTEGRATED_OPENCL_INCLUDES ${OPENCL_ICD_LOADER_HEADERS_DIR})
......
...@@ -63,7 +63,7 @@ build-backend = "scikit_build_core.build" ...@@ -63,7 +63,7 @@ build-backend = "scikit_build_core.build"
# based on https://github.com/scikit-build/scikit-build-core#configuration # based on https://github.com/scikit-build/scikit-build-core#configuration
[tool.scikit-build] [tool.scikit-build]
cmake.version = ">=3.18" cmake.version = ">=3.28"
ninja.version = ">=1.11" ninja.version = ">=1.11"
ninja.make-fallback = true ninja.make-fallback = true
cmake.args = [ cmake.args = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment