From 5d40bb42ba3888b9867fe6470f6d20bfd15eb8ee Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 29 Sep 2023 19:02:50 -0500 Subject: [PATCH] Fixed Some Windows CMake Issues - Fixed using dll instead of lib files when CMake has to build ACE/TAO. - Fixed static not linking - Added static windows build to GHA that builds ACE/TAO - CTest should now output logs on failures in GHA --- .github/workflows/build_and_test.yml | 48 ++++++++++++++++++++++++++++ cmake/ace_group.cmake | 28 ++++++++++------ cmake/scrape_vs.pl | 7 ++-- dds/DCPS/RTPS/MessageParser.h | 4 +-- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 12b75ecb7ac..2474b16273e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -63,6 +63,7 @@ concurrency: env: TRIGGERING_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg\installed + CTEST_OUTPUT_ON_FAILURE: ON jobs: @@ -12895,3 +12896,50 @@ jobs: run: | cd OpenDDS\build ctest -C Debug + + build_cmake_w22_stat: + + runs-on: windows-2022 + + steps: + - name: Checkout OpenDDS + uses: actions/checkout@v3 + with: + path: OpenDDS + submodules: true + - name: Checkout MPC + uses: actions/checkout@v3 + with: + repository: DOCGroup/MPC + path: MPC + - name: Checkout ACE_TAO + uses: actions/checkout@v3 + with: + repository: DOCGroup/ACE_TAO + ref: ace6tao2 + path: OpenDDS/ACE_TAO + - name: set up msvc env + uses: ilammy/msvc-dev-cmd@v1 + - name: Configure + shell: cmd + run: | + cd OpenDDS + cmake -B build^ + -DCMAKE_UNITY_BUILD=TRUE^ + -DBUILD_SHARED_LIBS=FALSE^ + -DCMAKE_BUILD_TYPE=Debug^ + -DOPENDDS_ACE=${{ github.workspace }}\OpenDDS\ACE_TAO\ACE^ + -DOPENDDS_MPC=${{ github.workspace }}\MPC^ + -DOPENDDS_BUILD_TESTS=TRUE^ + -DOPENDDS_CMAKE_VERBOSE=all + - uses: ammaraskar/msvc-problem-matcher@0.2.0 + - name: Build + shell: cmd + run: | + cd OpenDDS + cmake --build build + - name: Run Tests + shell: cmd + run: | + cd OpenDDS\build + ctest -C Debug diff --git a/cmake/ace_group.cmake b/cmake/ace_group.cmake index 139acfc3e24..2be04e2aff5 100644 --- a/cmake/ace_group.cmake +++ b/cmake/ace_group.cmake @@ -49,15 +49,25 @@ if(OPENDDS_XERCES3) endif() function(_opendds_vs_force_static) - # See https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace - foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - set(${flag_var} "${${flag_var}}" PARENT_SCOPE) - endif() - endforeach() + # Make sure the MSVC runtime library, which is similar to libc of other + # systems, is the same kind everywhere. Normally we shouldn't make global + # changes, but if we don't do this, MSVC won't link the programs if the + # runtimes of compiled objects are different. + if(CMAKE_VERSION VERSION_LESS 3.15.0) + # See https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + set(${flag_var} "${${flag_var}}" PARENT_SCOPE) + endif() + endforeach() + else() + # The above doesn't seem to work anymore, so use this newer setting to + # force it globally. + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE INTERNAL "" FORCE) + endif() endfunction() if(MSVC AND OPENDDS_STATIC) diff --git a/cmake/scrape_vs.pl b/cmake/scrape_vs.pl index a54bddcb843..b7dd089f874 100644 --- a/cmake/scrape_vs.pl +++ b/cmake/scrape_vs.pl @@ -52,7 +52,8 @@ if ($pf_line =~ /(\$\(OutDir\))?(.*)<\/OutputFile>$/) { my $out_dir = $1; my $output_file = $2; - $output_file =~ s/d?.dll/d.dll/; + $output_file =~ s/d?\.dll/d.dll/; + $output_file =~ s/\.dll$/.lib/; if ($out_dir) { my $dir = $output_file =~ /.exe/ ? 'bin' : 'lib'; $loc = File::Spec->catfile($values{ace}, $dir, $output_file); @@ -64,11 +65,11 @@ } } if (!defined($loc)) { - print STDERR ("Didn't get OutputFile from $pf\n"); + # print STDERR ("Didn't get OutputFile from $pf\n"); next; } - print STDERR ("$name $pf $loc\n"); + # print STDERR ("$name $pf $loc\n"); $projects{$name} = { name => $name, loc => $loc, diff --git a/dds/DCPS/RTPS/MessageParser.h b/dds/DCPS/RTPS/MessageParser.h index ca5db7d2679..ec7e5d012b3 100644 --- a/dds/DCPS/RTPS/MessageParser.h +++ b/dds/DCPS/RTPS/MessageParser.h @@ -1,6 +1,4 @@ /* - * - * * Distributed under the OpenDDS License. * See: http://www.opendds.org/license.html */ @@ -9,7 +7,7 @@ #define OPENDDS_DCPS_RTPS_MESSAGEPARSER_H #include "RtpsCoreTypeSupportImpl.h" - +#include "rtps_export.h" OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL