Skip to content

Commit

Permalink
Support non-VS generator on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Nov 27, 2023
1 parent c2ef751 commit 6b5f4bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 8 additions & 1 deletion nuget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions run_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6b5f4bc

Please sign in to comment.