From 10c6b35a7243bb6ba156f75ad0854fd009870c1a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 6 Jun 2024 19:18:42 -0500 Subject: [PATCH] Make CMake and Configure Fallback To Last Known VS --- cmake/get_ace_tao.cmake | 40 +++++++++++++++++++++++++++++----------- configure | 24 +++++++++++++++--------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/cmake/get_ace_tao.cmake b/cmake/get_ace_tao.cmake index 54b3b9b187e..28b723d0fba 100644 --- a/cmake/get_ace_tao.cmake +++ b/cmake/get_ace_tao.cmake @@ -4,22 +4,40 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) cmake_policy(SET CMP0135 NEW) endif() +function(_opendds_set_vs_mpc_type) + set(vs_vers + "Visual Studio 14 2015" vc14 + "Visual Studio 15 2017" vs2017 + "Visual Studio 16 2019" vs2019 + "Visual Studio 17 2022" vs2022 + ) + + set(mpc_vs_name) + list(LENGTH vs_vers vs_vers_count) + math(EXPR vs_vers_count_end "${vs_vers_count} - 1") + foreach(i RANGE 0 ${vs_vers_count_end} 2) + list(GET vs_vers ${i} cmake_name) + math(EXPR next "${i} + 1") + list(GET vs_vers ${next} mpc_name) + if(cmake_name STREQUAL CMAKE_GENERATOR) + set(mpc_vs_name "${mpc_name}") + break() + endif() + endforeach() + if(NOT mpc_vs_name) + message(STATUS "Missing a MPC project type for \"${CMAKE_GENERATOR}\", " + "using last known: \"${cmake_name}\"/${mpc_name}") + set(mpc_vs_name "${mpc_name}") + endif() + set(_OPENDDS_MPC_TYPE "${mpc_vs_name}" PARENT_SCOPE) +endfunction() + set(_OPENDDS_CONFIGURE_ACE_TAO_ARGS) set(ACE_IS_BEING_BUILT MPC CACHE INTERNAL "") set(TAO_IS_BEING_BUILT MPC CACHE INTERNAL "") if(WIN32) set(ext "zip") - if(CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022") - set(_OPENDDS_MPC_TYPE vs2022) - elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 16 2019") - set(_OPENDDS_MPC_TYPE vs2019) - elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017") - set(_OPENDDS_MPC_TYPE vs2017) - elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015") - set(_OPENDDS_MPC_TYPE vc14) - else() - set(_OPENDDS_MPC_TYPE vs2022) - endif() + _opendds_set_vs_mpc_type() set(_OPENDDS_ACE_CONFIG_FILE "config-win32.h") else() set(ext "tar.bz2") diff --git a/configure b/configure index 619d7ae87f3..1c5a8e08856 100755 --- a/configure +++ b/configure @@ -773,20 +773,26 @@ EOF if ($arch eq 'Unknown') { die "cl version probe failed, no known architecture macro was defined\nStopped"; } - if (!exists $platforminfo{'win32'}->{'cl_archs'}->{$arch}) { - die "cl version probe failed, invalid architecture \"$arch\"\nStopped"; + + my $archs = $platforminfo{'win32'}->{'cl_archs'}; + if (!exists($archs->{$arch})) { + die "cl version probe failed, unknown architecture \"$arch\"\nStopped"; } - if (!$platforminfo{'win32'}->{'cl_archs'}->{$arch}) { + if (!$archs->{$arch}) { die "ERROR: Windows for $arch isn't supported\nStopped"; } - if (!exists $platforminfo{'win32'}->{'cl_versions'}->{$ver}) { - die "ERROR: Unknown or unsupported Visual C++ compiler version: $ver\n" - . "Stopped"; - } - - $opts{'compiler_version'} = $platforminfo{'win32'}->{'cl_versions'}->{$ver}; $opts{'compiler_target_architecture'} = $arch; + my $vers = $platforminfo{'win32'}->{'cl_versions'}; + if (!exists($vers->{$ver})) { + my @vers_sorted = sort(keys(%{$vers})); + my $last_cl = $vers_sorted[-1]; + print "$ver isn't a known version of cl, using the last known version: $last_cl\n" + if $opts{'verbose'}; + $ver = $last_cl; + } + $opts{'compiler_version'} = $vers->{$ver}; + if ($ver >= 19) { push(@features, 'no_cxx11=0'); print "Visual C++ has >= C++11 support\n" if $opts{'verbose'};