mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-24 16:51:38 +08:00
[scripts|cmake] use ENV{VisualStudioVersion} to switch cmake generator (#26339)
* add VCPKG_CMAKE_VS_GENERATOR for overriding/providing a generator if ninja cannot be used * Wording CR. Co-authored-by: Javier Matos Denizac <javier.matosd@gmail.com> * use VisualStudioVersion to switch the generator. * v db * CR changes * v db Co-authored-by: Javier Matos Denizac <javier.matosd@gmail.com>
This commit is contained in:
parent
1d5b2d15ff
commit
ba1f91fd7e
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"version-date": "2022-07-18",
|
||||
"version-date": "2022-08-18",
|
||||
"documentation": "https://vcpkg.io/en/docs/maintainers/ports/vcpkg-cmake.html",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
@ -76,6 +76,14 @@ function(vcpkg_cmake_configure)
|
||||
if(arg_WINDOWS_USE_MSBUILD AND VCPKG_HOST_IS_WINDOWS AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
||||
z_vcpkg_get_visual_studio_generator(OUT_GENERATOR generator OUT_ARCH arch)
|
||||
vcpkg_list(APPEND architecture_options "-A${arch}")
|
||||
if(DEFINED VCPKG_PLATFORM_TOOLSET)
|
||||
vcpkg_list(APPEND arg_OPTIONS "-T${VCPKG_PLATFORM_TOOLSET}")
|
||||
endif()
|
||||
if(NOT generator)
|
||||
message(FATAL_ERROR "Unable to determine appropriate Visual Studio generator for triplet ${TARGET_TRIPLET}:
|
||||
ENV{VisualStudioVersion} : $ENV{VisualStudioVersion}
|
||||
VCPKG_TARGET_ARCHITECTURE: ${VCPKG_TARGET_ARCHITECTURE}")
|
||||
endif()
|
||||
elseif(DEFINED arg_GENERATOR)
|
||||
set(generator "${arg_GENERATOR}")
|
||||
elseif(ninja_host)
|
||||
|
@ -27,16 +27,22 @@ function(z_vcpkg_get_visual_studio_generator)
|
||||
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
if("${VCPKG_PLATFORM_TOOLSET}" STREQUAL "v120" AND NOT "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
|
||||
set(generator "Visual Studio 12 2013")
|
||||
elseif("${VCPKG_PLATFORM_TOOLSET}" STREQUAL "v140" AND NOT "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
|
||||
set(generator "Visual Studio 14 2015")
|
||||
elseif("${VCPKG_PLATFORM_TOOLSET}" STREQUAL "v141")
|
||||
set(generator "Visual Studio 15 2017")
|
||||
elseif("${VCPKG_PLATFORM_TOOLSET}" STREQUAL "v142")
|
||||
set(generator "Visual Studio 16 2019")
|
||||
elseif("${VCPKG_PLATFORM_TOOLSET}" STREQUAL "v143")
|
||||
set(generator "Visual Studio 17 2022")
|
||||
|
||||
if(DEFINED ENV{VisualStudioVersion})
|
||||
if("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "12.99" AND
|
||||
"$ENV{VisualStudioVersion}" VERSION_GREATER_EQUAL "12.0" AND
|
||||
NOT "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
|
||||
set(generator "Visual Studio 12 2013")
|
||||
elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "14.99" AND
|
||||
NOT "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64")
|
||||
set(generator "Visual Studio 14 2015")
|
||||
elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "15.99")
|
||||
set(generator "Visual Studio 15 2017")
|
||||
elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "16.99")
|
||||
set(generator "Visual Studio 16 2019")
|
||||
elseif("$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "17.99")
|
||||
set(generator "Visual Studio 17 2022")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "x86")
|
||||
@ -149,9 +155,13 @@ function(vcpkg_configure_cmake)
|
||||
if("${generator}" STREQUAL "" OR "${generator_arch}" STREQUAL "")
|
||||
message(FATAL_ERROR
|
||||
"Unable to determine appropriate generator for triplet ${TARGET_TRIPLET}:
|
||||
ENV{VisualStudioVersion} : $ENV{VisualStudioVersion}
|
||||
platform toolset: ${VCPKG_PLATFORM_TOOLSET}
|
||||
architecture : ${VCPKG_TARGET_ARCHITECTURE}")
|
||||
endif()
|
||||
if(DEFINED VCPKG_PLATFORM_TOOLSET)
|
||||
vcpkg_list(APPEND arg_OPTIONS "-T${VCPKG_PLATFORM_TOOLSET}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If we use Ninja, make sure it's on PATH
|
||||
|
@ -7589,7 +7589,7 @@
|
||||
"port-version": 0
|
||||
},
|
||||
"vcpkg-cmake": {
|
||||
"baseline": "2022-07-18",
|
||||
"baseline": "2022-08-18",
|
||||
"port-version": 0
|
||||
},
|
||||
"vcpkg-cmake-config": {
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "84c200e8e625d4d99b1649525fcdf81a73197078",
|
||||
"version-date": "2022-08-18",
|
||||
"port-version": 0
|
||||
},
|
||||
{
|
||||
"git-tree": "a7b618b7782f3c841d7fd2d84a6ba3619815362a",
|
||||
"version-date": "2022-07-18",
|
||||
|
Loading…
Reference in New Issue
Block a user