Skip to content

Commit

Permalink
Add support for Visual Studio 2022 (#4889)
Browse files Browse the repository at this point in the history
* Update .vsts-ci.yml

* Update .vsts-ci.yml

* Update Installation-Guide.rst

* Update install.libs.R

* Update setup.py

* Update r_package.yml

* Update install.libs.R
  • Loading branch information
StrikerRUS committed Dec 15, 2021
1 parent 9f13a9c commit 90a71b9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/r_package.yml
Expand Up @@ -98,6 +98,13 @@ jobs:
toolchain: MSVC
r_version: 4.0
build_type: cmake
# Visual Studio 2022
- os: windows-2022
task: r-package
compiler: MSVC
toolchain: MSVC
r_version: 4.0
build_type: cmake
###############
# CRAN builds #
###############
Expand Down
3 changes: 2 additions & 1 deletion R-package/src/install.libs.R
Expand Up @@ -65,7 +65,8 @@ if (!(R_int_UUID == "0310d4b8-ccb1-4bb8-ba94-d36a55f60262"
# try to generate Visual Studio build files
.generate_vs_makefiles <- function(cmake_args) {
vs_versions <- c(
"Visual Studio 16 2019"
"Visual Studio 17 2022"
, "Visual Studio 16 2019"
, "Visual Studio 15 2017"
, "Visual Studio 14 2015"
)
Expand Down
4 changes: 3 additions & 1 deletion docs/Installation-Guide.rst
Expand Up @@ -581,7 +581,9 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build.

Visual Studio 2017 -> ``msvc-14.1-64.exe``,

Visual Studio 2019 -> ``msvc-14.2-64.exe``.
Visual Studio 2019 -> ``msvc-14.2-64.exe``,

Visual Studio 2022 -> ``msvc-14.3-64.exe``.

4. Run the following commands:

Expand Down
9 changes: 7 additions & 2 deletions python-package/setup.py
Expand Up @@ -165,7 +165,7 @@ def compile_cpp(
lib_path = CURRENT_DIR / "compile" / "windows" / "x64" / "DLL" / "lib_lightgbm.dll"
if not any((use_gpu, use_cuda, use_mpi, use_hdfs, nomp, bit32, integrated_opencl)):
logger.info("Starting to compile with MSBuild from existing solution file.")
platform_toolsets = ("v142", "v141", "v140")
platform_toolsets = ("v143", "v142", "v141", "v140")
for pt in platform_toolsets:
status = silent_call(["MSBuild",
str(CURRENT_DIR / "compile" / "windows" / "LightGBM.sln"),
Expand All @@ -180,7 +180,12 @@ def compile_cpp(
logger.warning("Compilation with MSBuild from existing solution file failed.")
if status != 0 or not lib_path.is_file():
arch = "Win32" if bit32 else "x64"
vs_versions = ("Visual Studio 16 2019", "Visual Studio 15 2017", "Visual Studio 14 2015")
vs_versions = (
"Visual Studio 17 2022",
"Visual Studio 16 2019",
"Visual Studio 15 2017",
"Visual Studio 14 2015"
)
for vs in vs_versions:
logger.info(f"Starting to compile with {vs} ({arch}).")
status = silent_call(cmake_cmd + ["-G", vs, "-A", arch])
Expand Down

0 comments on commit 90a71b9

Please sign in to comment.