Skip to content

Commit

Permalink
[cmake] always target Windows SDK v10.x when using Visual Studio gene…
Browse files Browse the repository at this point in the history
…rators (fixes #6448) (#6451)
  • Loading branch information
jameslamb authored May 30, 2024
1 parent dee8a18 commit c07694b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c07694b

Please sign in to comment.