diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 03d2463f..47310bbf 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -13,47 +13,38 @@ defaults: jobs: build: runs-on: ubuntu-20.04 - name: ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} + name: ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} ${{ matrix.sys.stdlib }} strategy: fail-fast: false matrix: sys: - - {compiler: clang, version: '15'} - - {compiler: clang, version: '16'} - - {compiler: gcc, version: '11'} - - {compiler: gcc, version: '13'} + - {compiler: clang, version: '16', config-flags: '', stdlib: 'libstdc++-13' } + # - {compiler: clang, version: '16', config-flags: '-DCMAKE_CXX_FLAGS=-stdlib=libc++', stdlib: 'libc++-17' } + - {compiler: clang, version: '17', config-flags: '', stdlib: 'libstdc++-13' } + # - {compiler: clang, version: '17', config-flags: '-DCMAKE_CXX_FLAGS=-stdlib=libc++', stdlib: 'libc++-17' } + - {compiler: gcc, version: '13', config-flags: '' } steps: - - name: Setup GCC - if: ${{ matrix.sys.compiler == 'gcc' }} - run: | - GCC_VERSION=${{ matrix.sys.version }} - sudo apt-get update - sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION - CC=gcc-$GCC_VERSION - echo "CC=$CC" >> $GITHUB_ENV - CXX=g++-$GCC_VERSION - echo "CXX=$CXX" >> $GITHUB_ENV - - name: Setup clang - if: ${{ matrix.sys.compiler == 'clang' }} - run: | - LLVM_VERSION=${{ matrix.sys.version }} - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1 - if [[ $LLVM_VERSION -ge 13 ]]; then - sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_VERSION main" || exit 1 - else - sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" || exit 1 - fi || exit 1 - sudo apt-get update || exit 1 - sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION || exit 1 - sudo apt-get --no-install-suggests --no-install-recommends install g++-9 g++-9-multilib || exit 1 - sudo ln -s /usr/include/asm-generic /usr/include/asm - CC=clang-$LLVM_VERSION - echo "CC=$CC" >> $GITHUB_ENV - CXX=clang++-$LLVM_VERSION - echo "CXX=$CXX" >> $GITHUB_ENV + - name: Install GCC + if: matrix.sys.compiler == 'gcc' + uses: egor-tensin/setup-gcc@v1 + with: + version: ${{matrix.sys.version}} + platform: x64 + + - name: Install LLVM and Clang + if: matrix.sys.compiler == 'clang' + uses: egor-tensin/setup-clang@v1 + with: + version: ${{matrix.sys.version}} + platform: x64 + + - name: Install the specified standard library for clang + if: matrix.sys.compiler == 'clang' + run: sudo apt install ${{matrix.sys.stdlib}}-dev -y + - name: Checkout code uses: actions/checkout@v3 @@ -67,10 +58,7 @@ jobs: cache-downloads: true - name: Configure using CMake - # env: - # CC: ${{ env.CC }} - # CXX: ${{ env.CXX }} - run: cmake -G Ninja -Bbuild -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON + run: cmake -G Ninja -Bbuild ${{matrix.sys.config-flags}} -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON - name: Install working-directory: build diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 77489679..23ee2b6f 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -18,7 +18,6 @@ jobs: fail-fast: false matrix: os: - - 11 - 12 steps: diff --git a/.gitignore b/.gitignore index 9a8bc0f7..a2023b6b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ *.out *.app +# Ignore build directory +/build/ # Ignore VSCODE specific options (unless we want to provide shortcuts to build and run, then delete these) /.vscode/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 87b73e74..ba220811 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.28) + +# This is better specified per target, but cmake keeps ignoring these language version +# specification when building this project by itself, in particular the gnu extensions, +# so here we go. +# This will affects all following targets being defined. +set(CMAKE_CXX_EXTENSIONS OFF) + project(sparrow CXX) set(SPARROW_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -53,6 +60,8 @@ target_include_directories(sparrow INTERFACE $ $) +# We do not use non-standard C++ +set_target_properties(sparrow PROPERTIES CMAKE_CXX_EXTENSIONS OFF) target_compile_features(sparrow INTERFACE cxx_std_20) if (BUILD_TESTS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b0ced9e7..f260447c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,6 +14,7 @@ cmake_minimum_required(VERSION 3.8) + if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) project(sparrow-test CXX) @@ -40,3 +41,7 @@ set(SPARROW_TESTS set(test_target "test_sparrow_lib") add_executable(${test_target} ${SPARROW_TESTS}) target_link_libraries(${test_target} PRIVATE sparrow doctest::doctest) + +# We do not use non-standard C++ +set_target_properties(${test_target} PROPERTIES CMAKE_CXX_EXTENSIONS OFF) +target_compile_features(${test_target} PRIVATE cxx_std_20) diff --git a/test/main.cpp b/test/main.cpp index 0f3979c7..a89b6f8a 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -15,3 +15,4 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest/doctest.h" +#include