diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index a12733ef..aa2f199d 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -13,7 +13,7 @@ defaults: jobs: build: runs-on: macos-${{ matrix.os }} - name: ${{ matrix.os }}-${{ matrix.config.name }} + name: ${{ matrix.os }}-${{ matrix.config.name }}-${{ matrix.compiler }} strategy: fail-fast: false matrix: @@ -22,12 +22,20 @@ jobs: config: - { name: Debug } - { name: Release } + compiler: + - clang + - apple-clang steps: - name: Checkout code uses: actions/checkout@v3 + - name: Add specification of clang++ in the conda environment specification + if: matrix.compiler == 'clang' + run: | + echo " - clangxx==17.0.6" >> environment-dev.yml + - name: Set conda environment uses: mamba-org/setup-micromamba@main with: @@ -36,6 +44,18 @@ jobs: init-shell: bash cache-downloads: true + - name: Use clang++ from conda-forge + if: matrix.compiler == 'clang' + run: | + echo "CXX=$CONDA_PREFIX/bin/clang++" >> $GITHUB_ENV + echo "CMAKE_CXX_COMPILER=$CONDA_PREFIX/bin/clang++" >> $GITHUB_ENV + + - name: Use Apple Clang (i.e. clang++ from Xcode) + if: matrix.compiler == 'apple-clang' + run: | + echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV + echo "CMAKE_CXX_COMPILER=/usr/bin/clang++" >> $GITHUB_ENV + - name: Configure using CMake run: cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON diff --git a/include/sparrow/algorithm.hpp b/include/sparrow/algorithm.hpp index 63c1df12..eb941301 100644 --- a/include/sparrow/algorithm.hpp +++ b/include/sparrow/algorithm.hpp @@ -21,7 +21,7 @@ namespace sparrow { -#if COMPILING_WITH_APPLE_CLANG +#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17 template concept OrdCategory = std::same_as || std::same_as @@ -71,7 +71,7 @@ namespace sparrow constexpr auto lexicographical_compare_three_way(const R1& range1, const R2& range2, Cmp comp) -> decltype(comp(*range1.cbegin(), *range2.cbegin())) { -#if COMPILING_WITH_APPLE_CLANG +#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17 return lexicographical_compare_three_way_non_std(range1, range2, comp); #else return std::lexicographical_compare_three_way( @@ -84,7 +84,7 @@ namespace sparrow #endif } -#if COMPILING_WITH_APPLE_CLANG +#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17 struct compare_three_way { template @@ -109,7 +109,7 @@ namespace sparrow return lexicographical_compare_three_way( r1, r2, -#if COMPILING_WITH_APPLE_CLANG +#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17 compare_three_way {} #else std::compare_three_way{} diff --git a/include/sparrow/config.hpp b/include/sparrow/config.hpp index d473737e..3cc91b66 100644 --- a/include/sparrow/config.hpp +++ b/include/sparrow/config.hpp @@ -20,6 +20,12 @@ #define COMPILING_WITH_APPLE_CLANG 0 #endif +#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 170000 +#define USING_LIBCPP_PRE_17 1 +#else +#define USING_LIBCPP_PRE_17 0 +#endif + consteval bool is_apple_compiler() { return static_cast(COMPILING_WITH_APPLE_CLANG);