From 9a218e92b530a19b17585cc49d3c9dc8cf4f996b Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 6 May 2024 17:16:52 -0500 Subject: [PATCH] Test _MSVC_LANG instead of __cplusplus for CMake --- cmake/init.cmake | 5 ----- cmake/test_cxx_std.cpp | 6 +++++- docs/news.d/cmake-ace-tao-cpp-std.rst | 9 +++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmake/init.cmake b/cmake/init.cmake index b5717714f93..96f7d489075 100644 --- a/cmake/init.cmake +++ b/cmake/init.cmake @@ -178,15 +178,10 @@ function(_opendds_set_cxx_std) # Get the latest known default compiler C++ standard set(default_cxx_std_year 1998) foreach(cplusplus IN LISTS cplusplus_values) - set(args) - if(MSVC AND NOT MSVC_VERSION LESS 1914) - list(APPEND args CMAKE_FLAGS "-DCMAKE_CXX_FLAGS=/Zc:__cplusplus") - endif() try_compile(compiled "${temp_dir}/cplusplus_${cplusplus}" SOURCES "${test_cxx_std}" COMPILE_DEFINITIONS "-DOPENDDS_TEST_CPLUSPLUS=${cplusplus}L" - ${args} ) if(compiled) _opendds_cplusplus_to_year(default_cxx_std_year ${cplusplus}) diff --git a/cmake/test_cxx_std.cpp b/cmake/test_cxx_std.cpp index 969068816cb..da063eb1e2f 100644 --- a/cmake/test_cxx_std.cpp +++ b/cmake/test_cxx_std.cpp @@ -1,5 +1,9 @@ #ifdef OPENDDS_TEST_CPLUSPLUS -# if __cplusplus < OPENDDS_TEST_CPLUSPLUS +# ifdef _MSVC_LANG +# if _MSVC_LANG < OPENDDS_TEST_CPLUSPLUS +# error "Less then requested value" +# endif +# elif __cplusplus < OPENDDS_TEST_CPLUSPLUS # error "Less then requested value" # endif #elif defined OPENDDS_TEST_ACE_CXX_STD diff --git a/docs/news.d/cmake-ace-tao-cpp-std.rst b/docs/news.d/cmake-ace-tao-cpp-std.rst index 8f52ea8444f..e582401dff9 100644 --- a/docs/news.d/cmake-ace-tao-cpp-std.rst +++ b/docs/news.d/cmake-ace-tao-cpp-std.rst @@ -1,5 +1,10 @@ .. news-prs: 4618 .. news-start-section: Platform Support and Dependencies -- Fix cases where the CMake support fails when using the ACE/TAO master branch because it now requires C++17. -.. news-end-section. news-end-section +.. news-start-section: CMake +- Allow using the ACE/TAO master branch which now requires C++17. +.. news-end-section +.. news-start-section: Building with CMake +- Visual Studio now defaults to using at least C++11 with ACE 6/TAO 2 instead of C++03. +.. news-end-section +.. news-end-section