From f8123153d473434a6875a7fc2dfabb68421f156b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 8 May 2024 22:57:02 -0500 Subject: [PATCH 1/2] [cmake] always target Windows SDK v10.x when using Visual Studio generators --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bb8e6b41794..c65cfcb29829 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,14 @@ option(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Lo cmake_minimum_required(VERSION 3.18) +# 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 +# outdated registry entries. +# ref: https://cmake.org/cmake/help/latest/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.html +if (CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_SYSTEM_VERSION 10.0 CACHE INTERNAL "target Windows SDK version" FORCE) +endif() + project(lightgbm LANGUAGES C CXX) if(BUILD_CPP_TEST) From 6abbd2c8fd2fc253e6a1bcd2f70b482a7f976f7f Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 8 May 2024 23:07:51 -0500 Subject: [PATCH 2/2] formatting --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c65cfcb29829..7cec8b1ff290 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ cmake_minimum_required(VERSION 3.18) # Doing this avoids lookups that could fall back to very old versions, e.g. by finding # outdated registry entries. # ref: https://cmake.org/cmake/help/latest/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.html -if (CMAKE_GENERATOR MATCHES "Visual Studio") +if(CMAKE_GENERATOR MATCHES "Visual Studio") set(CMAKE_SYSTEM_VERSION 10.0 CACHE INTERNAL "target Windows SDK version" FORCE) endif()