diff --git a/nuget.cmake b/nuget.cmake index 8bfac58..8ddce7c 100644 --- a/nuget.cmake +++ b/nuget.cmake @@ -77,7 +77,14 @@ function(nuget_add_winrt target_name) set(gen_dst ${CMAKE_BINARY_DIR}/packages/gen) file(MAKE_DIRECTORY ${gen_dst}/winrt) - set(winrt_sdk_version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) + set(winrt_sdk_version) + if (NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + endif() + # https://gitlab.kitware.com/cmake/cmake/-/blob/89cfb90b9c0893133983b4f25896671c4f07497c/Modules/InstallRequiredSystemLibraries.cmake#L381 + if (";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;([0-9.]+)[;\]]=]) + set(winrt_sdk_version ${CMAKE_MATCH_1}) + endif() set(winrt_version_key ${gen_dst}/winrt/version_key) set(winrt_version_test ${winrt_version_key}_test) set(sdk_version_key ${gen_dst}/winrt/sdk_version_key) diff --git a/run_cmake.py b/run_cmake.py index 74f2e1e..97717d9 100644 --- a/run_cmake.py +++ b/run_cmake.py @@ -11,24 +11,24 @@ def run(project, arguments, buildType=''): basePath = scriptPath + '/../out/' + buildType cmake = ['cmake'] - windowsArch = '' + vsArch = '' explicitGenerator = False for arg in arguments: if arg == 'debug': cmake.append('-DCMAKE_BUILD_TYPE=Debug') elif arg == 'x86' or arg == 'x64': - windowsArch = arg + vsArch = arg elif arg != 'force': if arg.startswith('-G'): explicitGenerator = True cmake.append(arg) - if sys.platform == 'win32': - if windowsArch == 'x64': + if sys.platform == 'win32' and not explicitGenerator: + if vsArch == 'x64': cmake.append('-Ax64') else: cmake.append('-AWin32') # default - elif windowsArch != '': - print("[ERROR] x86/x64 switch is supported only on Windows.") + elif vsArch != '': + print("[ERROR] x86/x64 switch is supported only with Visual Studio.") return 1 elif sys.platform == 'darwin': if not explicitGenerator: