diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4b533149..c8f849df1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,6 +63,51 @@ jobs: id: hash-gcc run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" + build-linux-cpp-std: + name: Build Linux C++ + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + std: [11, 14, 17, 20, 23] + cxx: [g++-10, clang++-12] + exclude: + # GCC 10.3.0 doesn't support std 23 + - cxx: g++-10 + std: 23 + steps: + - uses: actions/checkout@v2 + - name: cmake + run: > + CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" + -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON + -DFLATBUFFERS_CPP_STD=${{ matrix.std }} + - name: build + run: make -j + - name: test + run: ./flattests + + build-windows-cpp-std: + name: Build Windows C++ + runs-on: windows-2019 + strategy: + matrix: + std: [11, 14, 17, 20, 23] + fail-fast: false + steps: + - uses: actions/checkout@v2 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + - name: cmake + run: > + cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release + -DFLATBUFFERS_STRICT_MODE=ON + -DFLATBUFFERS_CPP_STD=${{ matrix.std }} + - name: build + run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 + - name: test + run: Release\flattests.exe + build-windows: permissions: contents: write diff --git a/CMakeLists.txt b/CMakeLists.txt index 46bb734d1..6cf690f8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,10 @@ option(FLATBUFFERS_STRICT_MODE "Build flatbuffers with all warnings as errors (-Werror or /WX)." OFF) +if(NOT DEFINED FLATBUFFERS_CPP_STD) + set(FLATBUFFERS_CPP_STD 11) +endif() + set(MSVC_LIKE OFF) if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") set(MSVC_LIKE ON) @@ -334,7 +338,7 @@ include_directories(grpc) add_library(ProjectConfig INTERFACE) target_compile_features(ProjectConfig INTERFACE - cxx_std_11 + cxx_std_${FLATBUFFERS_CPP_STD} ) # Force the standard to be met. diff --git a/include/flatbuffers/stl_emulation.h b/include/flatbuffers/stl_emulation.h index 97652b170..c930b67dc 100644 --- a/include/flatbuffers/stl_emulation.h +++ b/include/flatbuffers/stl_emulation.h @@ -46,6 +46,7 @@ #include #elif defined(__cpp_lib_span) && defined(__has_include) #if __has_include() + #include #include #define FLATBUFFERS_USE_STD_SPAN #endif