mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Merge pull request #2 from DwifteJB/msvc-winsysroot-fix
fix: if WINDOWS_SDK_PATH is not defined, find via find_program
This commit is contained in:
commit
6e35674c7d
|
|
@ -7,13 +7,34 @@ set(CMAKE_LINKER lld-link)
|
|||
set(CMAKE_C_COMPILER_FRONTEND_VARIANT MSVC)
|
||||
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MSVC)
|
||||
|
||||
# TODO add check that WINDOWS_SDK_PATH is real
|
||||
|
||||
set(WINDOWS_SDK_PATH "" CACHE PATH "Path to Windows SDK root")
|
||||
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES WINDOWS_SDK_PATH) # You have no idea how much suffering I went through to get this solution. I hate this build system with all my
|
||||
|
||||
message(STATUS "WINDOWS_SDK_PATH=${WINDOWS_SDK_PATH}")
|
||||
|
||||
if(NOT WINDOWS_SDK_PATH)
|
||||
if(DEFINED ENV{WINDOWS_SDK_PATH})
|
||||
# rm: check if defined within env instead
|
||||
set(WINDOWS_SDK_PATH $ENV{WINDOWS_SDK_PATH})
|
||||
else()
|
||||
# rm: not found? check to find msbuild wrapper from mscv-wine
|
||||
find_program(_msbuild_exe msbuild)
|
||||
if(_msbuild_exe)
|
||||
get_filename_component(_msbuild_bin ${_msbuild_exe} DIRECTORY) # .../bin/x64
|
||||
get_filename_component(_candidate "${_msbuild_bin}/.." ABSOLUTE) # .../bin
|
||||
if(NOT IS_DIRECTORY "${_candidate}/vc")
|
||||
get_filename_component(_candidate "${_candidate}/.." ABSOLUTE) # .../<root>
|
||||
endif()
|
||||
message(STATUS "Found Windows SDK Path in ${_candidate}")
|
||||
set(WINDOWS_SDK_PATH ${_candidate})
|
||||
else()
|
||||
# rm: assume /opt/msvc as a fallback (which is usually the default path)
|
||||
message(STATUS "Fallback to ${_candidate}")
|
||||
set(WINDOWS_SDK_PATH /opt/msvc)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${WINDOWS_SDK_PATH}/kits/10/Include")
|
||||
message(FATAL_ERROR "Invalid WINDOWS_SDK_PATH: ${WINDOWS_SDK_PATH}")
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Reference in a new issue