From afe661cacd58f20bb730ffde0775c9deb4bfa5cf Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Mon, 12 Jul 2021 13:39:30 -0700 Subject: [PATCH] Add support for VS2022 (#2065) * Add generation code for VS, cleanup Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Remove unused code and fixed comments of what is supported Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Code review comments Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- .../Common/MSVC/Configurations_msvc.cmake | 41 ++++--------------- .../Platform/Common/VisualStudio_common.cmake | 21 ++++------ 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake index 1850bec114..8b3a1eee49 100644 --- a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake +++ b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake @@ -8,39 +8,16 @@ include(cmake/Platform/Common/Configurations_common.cmake) include(cmake/Platform/Common/VisualStudio_common.cmake) -set(LY_MSVC_SUPPORTED_GENERATORS - "Visual Studio 15" - "Visual Studio 16" -) -set(FOUND_SUPPORTED_GENERATOR) -foreach(supported_generator ${LY_MSVC_SUPPORTED_GENERATORS}) - if(CMAKE_GENERATOR MATCHES ${supported_generator}) - set(FOUND_SUPPORTED_GENERATOR TRUE) - break() - endif() -endforeach() -# VS2017's checks since it defaults the toolchain and target architecture to x86 -if(CMAKE_GENERATOR MATCHES "Visual Studio 15") - if(CMAKE_VS_PLATFORM_NAME AND CMAKE_VS_PLATFORM_NAME STREQUAL "Win32") # VS2017 has Win32 as the default architecture - message(FATAL_ERROR "Win32 architecture not supported, specify \"-A x64\" when invoking cmake") - endif() - if(NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE STREQUAL "x64") # There is at least one library (EditorLib) that make the x86 linker to run out of memory - message(FATAL_ERROR "x86 toolset not supported, specify \"-T host=x64\" when invoking cmake") - endif() -else() - # For the other cases, verify that it wasn't invoked with an unsupported architecture. defaults to x86 architecture - if(SUPPORTED_VS_PLATFORM_NAME_OVERRIDE) - set(SUPPORTED_VS_PLATFORM_NAME ${SUPPORTED_VS_PLATFORM_NAME_OVERRIDE}) - else() - set(SUPPORTED_VS_PLATFORM_NAME x64) - endif() +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 1[6-7]") + message(FATAL_ERROR "Generator ${CMAKE_GENERATOR} not supported") +endif() - if(CMAKE_VS_PLATFORM_NAME AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "${SUPPORTED_VS_PLATFORM_NAME}") - message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} architecture not supported") - endif() - if(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE AND NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE STREQUAL "x64") - message(FATAL_ERROR "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE} toolset not supported") - endif() +# Verify that it wasn't invoked with an unsupported target/host architecture. Currently only supports x64/x64 +if(CMAKE_VS_PLATFORM_NAME AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "x64") + message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} target architecture is not supported, it must be 'x64'") +endif() +if(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE AND NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE STREQUAL "x64") + message(FATAL_ERROR "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE} host toolset is not supported, it must be 'x64'") endif() ly_append_configurations_options( diff --git a/cmake/Platform/Common/VisualStudio_common.cmake b/cmake/Platform/Common/VisualStudio_common.cmake index 91817bef6f..982d32f558 100644 --- a/cmake/Platform/Common/VisualStudio_common.cmake +++ b/cmake/Platform/Common/VisualStudio_common.cmake @@ -5,16 +5,13 @@ # # -if(CMAKE_GENERATOR MATCHES "Visual Studio 16") +foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + if(conf STREQUAL debug) + string(APPEND VCPKG_CONFIGURATION_MAPPING " Debug\n") + else() + string(APPEND VCPKG_CONFIGURATION_MAPPING " Release\n") + endif() +endforeach() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/Directory.Build.props" "${CMAKE_BINARY_DIR}/Directory.Build.props" @ONLY) - foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) - if(conf STREQUAL debug) - string(APPEND VCPKG_CONFIGURATION_MAPPING " Debug\n") - else() - string(APPEND VCPKG_CONFIGURATION_MAPPING " Release\n") - endif() - endforeach() - - configure_file("${CMAKE_CURRENT_LIST_DIR}/Directory.Build.props" "${CMAKE_BINARY_DIR}/Directory.Build.props" @ONLY) - -endif() \ No newline at end of file