From 4fbdccb89c89f2253ae8c3fbe830e69e338ae1ac Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 12 Sep 2023 16:09:47 -0400 Subject: [PATCH] Squashed 'externals/coda-oss/' changes from c92a55d7c7..14f0b1545c 14f0b1545c Merge branch 'main' into cpp17 a8c5a3b2b2 Merge branch 'main' into cpp17 5f858856e7 match code from 'main' 885e02a95d Merge branch 'main' into cpp17 436289c928 GCC 11 matches RH devtoolset-11 2a1ea98fb9 use GCC 10 on build server ba9851db60 restore C++17 git-subtree-dir: externals/coda-oss git-subtree-split: 14f0b1545c324fb0887289ec4bbfc6a67ffa61b6 --- .github/workflows/build_unittest.yml | 9 +++++-- CMakeLists.txt | 2 +- UnitTest/UnitTest.vcxproj | 5 ++++ build/build.py | 17 ++++--------- modules/c++/coda-oss.vcxproj | 6 +++++ modules/c++/coda-oss.vcxproj.filters | 3 --- .../c++/coda_oss/include/coda_oss/CPlusPlus.h | 4 +-- .../c++/coda_oss/include/coda_oss/cstddef.h | 17 ++----------- modules/c++/std/include/std/cstddef | 25 +------------------ modules/c++/str/include/str/Manip.h | 9 ------- 10 files changed, 29 insertions(+), 68 deletions(-) diff --git a/.github/workflows/build_unittest.yml b/.github/workflows/build_unittest.yml index fe1bae58d..2154ff7b8 100644 --- a/.github/workflows/build_unittest.yml +++ b/.github/workflows/build_unittest.yml @@ -109,7 +109,10 @@ jobs: run: | env which python - mkdir target && cd target + mkdir target + cd target + export CC=gcc-11 + export CXX=g++-11 cmake .. -DCMAKE_INSTALL_PREFIX=install${{ matrix.os }}CMake-Github -DPYTHON_VERSION=${{ matrix.python-version }} -DENABLE_SWIG=ON - name: build run: | @@ -153,7 +156,7 @@ jobs: build-waf: strategy: matrix: - os: [ubuntu-latest, windows-2019] + os: [ubuntu-latest] python-version: ['3.7'] debugging: ['--enable-debugging', ''] name: ${{ matrix.os }}-${{ matrix.python-version }}-waf${{ matrix.debugging }} @@ -169,6 +172,8 @@ jobs: run: | pip install numpy mkdir install${{ matrix.os }}Waf-Github + export CC=gcc-11 + export CXX=g++-11 python waf configure --prefix="$PWD/install${{ matrix.os }}Waf-Github" --enable-swig ${{ matrix.debugging }} - name: configure_without_swig if: ${{ matrix.os == 'windows-2019' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b1bc2c64..6ef7c1b35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.14) project(coda-oss) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CXX_STANDARD_REQUIRED true) if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") diff --git a/UnitTest/UnitTest.vcxproj b/UnitTest/UnitTest.vcxproj index f06331de9..a0585026c 100644 --- a/UnitTest/UnitTest.vcxproj +++ b/UnitTest/UnitTest.vcxproj @@ -71,6 +71,9 @@ true /Zc:__cplusplus %(AdditionalOptions) AdvancedVectorExtensions2 + stdcpp17 + stdc11 + MultiThreadedDebugDLL Windows @@ -96,6 +99,8 @@ true /Zc:__cplusplus %(AdditionalOptions) AdvancedVectorExtensions2 + stdcpp17 + stdc11 Windows diff --git a/build/build.py b/build/build.py index 01d512e98..a247788f8 100644 --- a/build/build.py +++ b/build/build.py @@ -756,7 +756,7 @@ def options(opt): opt.add_option('--enable-debugging', action='store_true', dest='debugging', help='Enable debugging') opt.add_option('--enable-cpp11', action='callback', callback=deprecated_callback) - opt.add_option('--enable-cpp17', action='store_true', dest='enablecpp17') + opt.add_option('--enable-cpp17', action='callback', callback=deprecated_callback) opt.add_option('--enable-64bit', action='callback', callback=deprecated_callback) opt.add_option('--enable-32bit', action='callback', callback=deprecated_callback) opt.add_option('--with-cflags', action='store', nargs=1, dest='cflags', @@ -812,7 +812,7 @@ def options(opt): 'results. NOOP if junit_xml cannot be imported') -def ensureCpp14Support(self): +def ensureCpp17Support(self): # DEPRECATED. # Keeping for now in case downstream code is still looking for it self.env['cpp11support'] = True @@ -914,10 +914,7 @@ def configureCompilerOptions(self): config['cxx']['optz_fastest-possible'] = [ config['cxx']['optz_faster'], '-march=native' ] # -march=native instead of haswell self.env.append_value('CXXFLAGS', '-fPIC'.split()) - if not Options.options.enablecpp17: - gxxCompileFlags='-std=c++14' - else: - gxxCompileFlags='-std=c++17' + gxxCompileFlags='-std=c++17' self.env.append_value('CXXFLAGS', gxxCompileFlags.split()) # DEFINES and LINKFLAGS will apply to both gcc and g++ @@ -1027,11 +1024,7 @@ def configureCompilerOptions(self): 'WIN32 _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN'.split() flags = '/UUNICODE /U_UNICODE /EHs /GR'.split() - #If building with cpp17 add flags/defines to enable auto_ptr - if Options.options.enablecpp17: - flags.append('/std:c++17') - else: - flags.append('/std:c++14') + flags.append('/std:c++17') self.env.append_value('DEFINES', defines) self.env.append_value('CXXFLAGS', flags) @@ -1252,7 +1245,7 @@ def configure(self): if Options.options._defs: env.append_unique('DEFINES', Options.options._defs.split(',')) configureCompilerOptions(self) - ensureCpp14Support(self) + ensureCpp17Support(self) env['PLATFORM'] = sys_platform diff --git a/modules/c++/coda-oss.vcxproj b/modules/c++/coda-oss.vcxproj index e2b2a306d..3b81ab370 100644 --- a/modules/c++/coda-oss.vcxproj +++ b/modules/c++/coda-oss.vcxproj @@ -582,6 +582,9 @@ AdvancedVectorExtensions2 MultiThreadedDebugDLL true + stdcpp17 + stdc11 + true @@ -609,6 +612,9 @@ true /Zc:__cplusplus %(AdditionalOptions) AdvancedVectorExtensions2 + stdcpp17 + stdc11 + true diff --git a/modules/c++/coda-oss.vcxproj.filters b/modules/c++/coda-oss.vcxproj.filters index 50db46175..1a54be81b 100644 --- a/modules/c++/coda-oss.vcxproj.filters +++ b/modules/c++/coda-oss.vcxproj.filters @@ -36,9 +36,6 @@ coda_oss - - coda_oss - coda_oss diff --git a/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h b/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h index ab528a085..887579a5c 100644 --- a/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h +++ b/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h @@ -79,8 +79,8 @@ #define CODA_OSS_cpp20 (CODA_OSS_cplusplus >= CODA_OSS_cplusplus20) #define CODA_OSS_cpp23 (CODA_OSS_cplusplus >= CODA_OSS_cplusplus23) -#if !CODA_OSS_cpp14 -#error "Must compile with C++14 or greater." +#if !CODA_OSS_cpp17 +#error "Must compile with C++17 or greater." #endif // Get feature-testing macros: https://en.cppreference.com/w/cpp/feature_test diff --git a/modules/c++/coda_oss/include/coda_oss/cstddef.h b/modules/c++/coda_oss/include/coda_oss/cstddef.h index c8c51ed42..68a7ad5dc 100644 --- a/modules/c++/coda_oss/include/coda_oss/cstddef.h +++ b/modules/c++/coda_oss/include/coda_oss/cstddef.h @@ -18,28 +18,15 @@ * License along with this program; If not, http://www.gnu.org/licenses/. * */ +#pragma once #ifndef CODA_OSS_coda_oss_cstddef_h_INCLUDED_ #define CODA_OSS_coda_oss_cstddef_h_INCLUDED_ -#pragma once - -#include #include -#include - -// Need a fairly decent C++ compiler to use the real GSL. This brings in more than -// we really need for span (e.g., gsl::narrow()), but it keeps things simple. -#include "gsl/gsl.h" // not gsl/byte; need #pragma here to turn off warnings namespace coda_oss { - #if defined(GSL_BYTE_H) // the above #include'd gsl/byte - using gsl::byte; - #else // no gsl::byte, use our own - // https://en.cppreference.com/w/cpp/types/byte - enum class byte : unsigned char {}; - #endif // GSL_BYTE_H + using byte = std::byte; } -static_assert(!std::is_same::value, "'coda_oss::byte' should be a unique type."); #endif // CODA_OSS_coda_oss_cstddef_h_INCLUDED_ diff --git a/modules/c++/std/include/std/cstddef b/modules/c++/std/include/std/cstddef index 10ba7deac..794d21efb 100644 --- a/modules/c++/std/include/std/cstddef +++ b/modules/c++/std/include/std/cstddef @@ -18,33 +18,10 @@ * License along with this program; If not, http://www.gnu.org/licenses/. * */ +#pragma once #ifndef CODA_OSS_std_cstddef_INCLUDED_ #define CODA_OSS_std_cstddef_INCLUDED_ -#pragma once - -#include #include -#include -#include "coda_oss/cstddef.h" -#include "coda_oss/CPlusPlus.h" - -// Make it (too?) easy for clients to get our various std:: implementations -#ifndef CODA_OSS_NO_std_byte - #if defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603L) // https://en.cppreference.com/w/cpp/utility/feature_test - #undef CODA_OSS_NO_std_byte - #define CODA_OSS_NO_std_byte 1 // provided by implementation, probably C++20 - #else - #define CODA_OSS_NO_std_byte 0 // use our own - #endif -#endif - -#if !CODA_OSS_NO_std_byte -namespace std // This is slightly uncouth: we're not supposed to augment "std". -{ - using coda_oss::byte; -} -static_assert(!std::is_same::value, "'std::byte' should be a unique type."); -#endif // !CODA_OSS_NO_std_byte #endif // CODA_OSS_std_cstddef_INCLUDED_ \ No newline at end of file diff --git a/modules/c++/str/include/str/Manip.h b/modules/c++/str/include/str/Manip.h index 0b48673a5..ee95a4663 100644 --- a/modules/c++/str/include/str/Manip.h +++ b/modules/c++/str/include/str/Manip.h @@ -46,16 +46,7 @@ CODA_OSS_disable_warning_push template inline CharT* data(std::basic_string& s) noexcept { - #if CODA_OSS_cpp17 return s.data(); - #else - CODA_OSS_disable_warning_push - #if _MSC_VER - #pragma warning(disable : 26492) // Don't use const_cast to cast away const or volatile (type.3). - #endif - return const_cast ::pointer>(s.data()); - CODA_OSS_disable_warning_pop - #endif // CODA_OSS_cpp17 } CODA_OSS_disable_warning_pop template