Skip to content

Commit 28056b8

Browse files
authored
Support clang++ from conda-forge (#81)
Support clang++ from conda-forge and backport implementation when libc++<17 is used
1 parent 3f996ab commit 28056b8

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

.github/workflows/osx.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defaults:
1313
jobs:
1414
build:
1515
runs-on: macos-${{ matrix.os }}
16-
name: ${{ matrix.os }}-${{ matrix.config.name }}
16+
name: ${{ matrix.os }}-${{ matrix.config.name }}-${{ matrix.compiler }}
1717
strategy:
1818
fail-fast: false
1919
matrix:
@@ -22,12 +22,20 @@ jobs:
2222
config:
2323
- { name: Debug }
2424
- { name: Release }
25+
compiler:
26+
- clang
27+
- apple-clang
2528

2629
steps:
2730

2831
- name: Checkout code
2932
uses: actions/checkout@v3
3033

34+
- name: Add specification of clang++ in the conda environment specification
35+
if: matrix.compiler == 'clang'
36+
run: |
37+
echo " - clangxx==17.0.6" >> environment-dev.yml
38+
3139
- name: Set conda environment
3240
uses: mamba-org/setup-micromamba@main
3341
with:
@@ -36,6 +44,18 @@ jobs:
3644
init-shell: bash
3745
cache-downloads: true
3846

47+
- name: Use clang++ from conda-forge
48+
if: matrix.compiler == 'clang'
49+
run: |
50+
echo "CXX=$CONDA_PREFIX/bin/clang++" >> $GITHUB_ENV
51+
echo "CMAKE_CXX_COMPILER=$CONDA_PREFIX/bin/clang++" >> $GITHUB_ENV
52+
53+
- name: Use Apple Clang (i.e. clang++ from Xcode)
54+
if: matrix.compiler == 'apple-clang'
55+
run: |
56+
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
57+
echo "CMAKE_CXX_COMPILER=/usr/bin/clang++" >> $GITHUB_ENV
58+
3959
- name: Configure using CMake
4060
run: cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON
4161

include/sparrow/algorithm.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace sparrow
2323
{
24-
#if COMPILING_WITH_APPLE_CLANG
24+
#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17
2525

2626
template <typename T>
2727
concept OrdCategory = std::same_as<T, std::strong_ordering> || std::same_as<T, std::weak_ordering>
@@ -71,7 +71,7 @@ namespace sparrow
7171
constexpr auto lexicographical_compare_three_way(const R1& range1, const R2& range2, Cmp comp)
7272
-> decltype(comp(*range1.cbegin(), *range2.cbegin()))
7373
{
74-
#if COMPILING_WITH_APPLE_CLANG
74+
#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17
7575
return lexicographical_compare_three_way_non_std(range1, range2, comp);
7676
#else
7777
return std::lexicographical_compare_three_way(
@@ -84,7 +84,7 @@ namespace sparrow
8484
#endif
8585
}
8686

87-
#if COMPILING_WITH_APPLE_CLANG
87+
#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17
8888
struct compare_three_way
8989
{
9090
template <class T, class U>
@@ -109,7 +109,7 @@ namespace sparrow
109109
return lexicographical_compare_three_way<R1, R2>(
110110
r1,
111111
r2,
112-
#if COMPILING_WITH_APPLE_CLANG
112+
#if COMPILING_WITH_APPLE_CLANG || USING_LIBCPP_PRE_17
113113
compare_three_way {}
114114
#else
115115
std::compare_three_way{}

include/sparrow/config.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#define COMPILING_WITH_APPLE_CLANG 0
2121
#endif
2222

23+
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 170000
24+
#define USING_LIBCPP_PRE_17 1
25+
#else
26+
#define USING_LIBCPP_PRE_17 0
27+
#endif
28+
2329
consteval bool is_apple_compiler()
2430
{
2531
return static_cast<bool>(COMPILING_WITH_APPLE_CLANG);

0 commit comments

Comments
 (0)