Skip to content

Commit

Permalink
Merge pull request OpenDDS#4681 from iguessthislldo/igtd/vs-vers
Browse files Browse the repository at this point in the history
Make CMake and Configure Fallback To Last Known VS
  • Loading branch information
jrw972 authored Jun 7, 2024
2 parents 0928f86 + 10c6b35 commit 57edcce
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 20 deletions.
40 changes: 29 additions & 11 deletions cmake/get_ace_tao.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
24 changes: 15 additions & 9 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down

0 comments on commit 57edcce

Please sign in to comment.