diff options
| author | silvanshade <[email protected]> | 2025-04-03 14:22:54 -0600 |
|---|---|---|
| committer | Henrik Gaßmann <[email protected]> | 2025-04-17 16:53:36 +0200 |
| commit | 70c8fe96a9535e122f8b70777d01aab8ca18fa73 (patch) | |
| tree | 1014057ef2869403c1294be565f628101d19bda1 | |
| parent | 0a56e1973a89ff06eae2ef069196c73dac6b3c54 (diff) | |
Add C++ std lib to pkg-config
| -rw-r--r-- | .github/workflows/ci.yml | 18 | ||||
| -rw-r--r-- | c/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | c/libblake3.pc.in | 2 |
3 files changed, 23 insertions, 6 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b28a5bc..296716f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -304,25 +304,33 @@ jobs: # Currently only on x86. pkg_config_c_tests: - name: pkg-config C tests TBB=${{ matrix.use_tbb }} BUILD_SHARED_LIBS=${{ matrix.shared_libs }} + name: pkg-config C tests TBB=${{ matrix.use_tbb }} BUILD_SHARED_LIBS=${{ matrix.shared_libs }} STDLIB=${{ matrix.stdlib }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: use_tbb: ["OFF", "ON"] shared_libs: ["OFF", "ON"] + stdlib: ["libc++", "libstdc++"] steps: - uses: actions/checkout@v4 - - run: | + - name: update packages + run: | sudo apt-get update sudo apt-get install ninja-build libtbb-dev libtbb12 - - run: cmake --fresh -S c -B c/build -G Ninja -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/target "-DBLAKE3_USE_TBB=${{ matrix.use_tbb }}" "-DBUILD_SHARED_LIBS=${{ matrix.shared_libs }}" + ${{ matrix.stdlib != 'libc++' || 'sudo apt-get install libc++-dev libc++abi-dev' }} + - name: configure cmake + run: | + export CXXFLAGS=${{ matrix.stdlib == 'libc++' && '-stdlib=libc++' || '' }} + export CC=${{ matrix.stdlib == 'libc++' && 'clang' || 'gcc' }} + export CXX=${{ matrix.stdlib == 'libc++' && 'clang++' || 'g++' }} + cmake --fresh -S c -B c/build -G Ninja -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/target "-DBLAKE3_USE_TBB=${{ matrix.use_tbb }}" "-DBUILD_SHARED_LIBS=${{ matrix.shared_libs }}" -DCMAKE_VERBOSE_MAKEFILE=1 - run: cmake --build c/build --target install - run: mkdir -p ${{ github.workspace }}/target/bin - run: echo "PKG_CONFIG_PATH=${{ github.workspace }}/target/lib/pkgconfig" >> $GITHUB_ENV - - run: gcc -O3 -o ${{ github.workspace }}/target/bin/blake3-example c/example.c $(pkg-config --cflags --libs libblake3) -lstdc++ + - run: gcc -O3 -o ${{ github.workspace }}/target/bin/blake3-example c/example.c $(pkg-config --cflags --libs libblake3) - if: matrix.use_tbb == 'ON' - run: gcc -O3 -o ${{ github.workspace }}/target/bin/blake3-example-tbb c/example_tbb.c $(pkg-config --cflags --libs libblake3) -lstdc++ + run: gcc -O3 -o ${{ github.workspace }}/target/bin/blake3-example-tbb c/example_tbb.c $(pkg-config --cflags --libs libblake3) # Note that this jobs builds AArch64 binaries from an x86_64 host. build_apple_silicon: diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index 6cd742d..13ef19b 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -242,6 +242,14 @@ if(BLAKE3_USE_TBB) endif() list(APPEND PKG_CONFIG_REQUIRES "tbb >= ${TBB_VERSION}") list(APPEND PKG_CONFIG_CFLAGS -DBLAKE3_USE_TBB) + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(_LIBCPP_VERSION "version" BLAKE3_HAVE_LIBCPP) + check_cxx_symbol_exists(__GLIBCXX__ "version" BLAKE3_HAVE_GLIBCXX) + if(BLAKE3_HAVE_GLIBCXX) + list(APPEND PKG_CONFIG_LIBS -lstdc++) + elseif(BLAKE3_HAVE_LIBCPP) + list(APPEND PKG_CONFIG_LIBS -lc++) + endif() endif() if(BLAKE3_USE_TBB) @@ -351,6 +359,7 @@ endfunction() # pkg-config support join_pkg_config_field(", " PKG_CONFIG_REQUIRES) +join_pkg_config_field(" " PKG_CONFIG_LIBS) join_pkg_config_field(" " PKG_CONFIG_CFLAGS) join_paths(PKG_CONFIG_INSTALL_LIBDIR "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") join_paths(PKG_CONFIG_INSTALL_INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/c/libblake3.pc.in b/c/libblake3.pc.in index e1a61e5..460dc90 100644 --- a/c/libblake3.pc.in +++ b/c/libblake3.pc.in @@ -8,5 +8,5 @@ Description: @PROJECT_DESCRIPTION@ Version: @PROJECT_VERSION@ Requires: @PKG_CONFIG_REQUIRES@ -Libs: -L"${libdir}" -lblake3 +Libs: -L"${libdir}" -lblake3 @PKG_CONFIG_LIBS@ Cflags: -I"${includedir}" @PKG_CONFIG_CFLAGS@ |
