Possibility to use [gtest, eigen, blaze, etc] from system-wide if they are installed in compilation time and not duplicate after installation
Hi, I would like to ask if is possible to change the following behavior. In Linux many dependencies are are available in the repositories, for instance,
-
gtest -
eigen -
blaze -
suitesparseprovides GraphBLAS. and so on.
I am trying to package, but I noticed that FetchContent download and later will install together fast_matrix_market.
pkgname=fast_matrix_market
pkgdesc="Fast and full-featured Matrix Market I/O library"
pkgver=1.7.6
pkgrel=1
arch=(x86_64)
url="https://github.com/alugowski/${pkgname}"
license=(BSD-2-Clause)
depends=(python)
makedepends=(python-build python-installer pybind11 python-scikit-build-core cmake)
checkdepends=(gtest suitesparse eigen blaze armadillo python-scipy python-threadpoolctl python-pytest)
optdepends=('eigen: '
'blaze: '
'armadillo: '
'python-scipy: ') # 'fastmatmr'
source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz)
sha512sums=('e97da2daf76770502e862a13b7b61aaf8797d9bec9d33f182ff28c2a0b3f8e8b078b559643d980d6c7f3ff57da9cf52bde8807120b9373e61851fd57373d51aa')
build() {
cmake \
-S ${pkgname}-${pkgver} \
-B build \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_SHARED_LIBS=TRUE \
-DCMAKE_CXX_STANDARD=23 \
-DFAST_MATRIX_MARKET_BENCH=ON \
-DFAST_MATRIX_MARKET_TEST=ON \
-DFMM_USE_DRAGONBOX=ON \
-DFMM_USE_FAST_FLOAT=ON \
-DFMM_USE_RYU=ON \
-Wno-dev
cmake --build build --target all
cd ${pkgname}-${pkgver}/python
python -m build --wheel --skip-dependency-check --no-isolation
}
check() {
ctest --verbose --output-on-failure --test-dir build
cd ${pkgname}-${pkgver}/python
python -m venv --system-site-packages test-env
test-env/bin/python -m installer dist/*.whl
test-env/bin/python -m pytest
}
package() {
DESTDIR="${pkgdir}" cmake --build build --target install
install -Dm 644 ${pkgname}-${pkgver}/LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
cd ${pkgname}-${pkgver}/python
PYTHONPYCACHEPREFIX="${PWD}/.cache/cpython/" python -m installer --destdir="${pkgdir}" dist/*.whl
rm -r ${pkgdir}/usr/include/{blaze,eigen3,gtest,gmock}
rm -r ${pkgdir}/usr/lib/cmake/GTest
rm -r ${pkgdir}/usr/share/{blaze,eigen3}
rm -r ${pkgdir}/usr/lib/lib{gmock*,gtest*}
rm -r ${pkgdir}/usr/lib/pkgconfig{gmock*,gtest*}
}
The solution could be manually delete files in order to avoid duplication for gtest, blaze, eigen, and so on post cmake installation
Hi @carlosal1015, can you clarify what you're trying to package? I see both C++ and Python dependencies mixed together even though those are separate packages.
There is already a good Python package on PyPI (built using the standard Python build methods), so I assume you're interested in packaging the C++ library? If so, drop all dependencies with python in their name.
For C++, the only dependency is a C++ 17 build system.
Eigen, Blaze, GraphBLAS, Armadillo, and such are optional test dependencies, to test the bindings for those libraries. FMM does not depend on those libraries in any way. To run the tests without these libraries, set FAST_MATRIX_MARKET_TEST_EXTERNAL_APPS to OFF.
https://github.com/alugowski/fast_matrix_market/blob/4477fc30975592196bf03830844a0f6828cee380/tests/CMakeLists.txt#L92C8-L92C45
That would drop all test dependencies apart from GTest, and I believe would not fetchcontent any of them.
Another option for just testing if the library is installed is to compile one of the tiny example problems instead of the entire test suite. If the sample1 example builds and runs then FMM is working. No GTest required at all. If I were packaging for Conan or vcpkg I'd do this.
If running the entire test suite is desired then I'm open to suggestions on how to pull in GTest. Note that this CMakeLists.txt needs to work on Windows and macOS too, not just Linux.
Couple questions:
- Why set
CMAKE_CXX_STANDARD? And why to 23 and not 17? - Why build the benchmark? drop
FAST_MATRIX_MARKET_BENCHor set it to OFF. The benchmark pulls in Google Benchmark (which itself needs GTest).
Thanks for the hint -DFAST_MATRIX_MARKET_TEST_EXTERNAL_APPS=OFF helped, no more files put over /usr/include/blaze, /usr/include/eigen3.
I setup C++23, because in this line it uses, but I move to C++ 17 now. Now is simplified, in this step I will focus only C+++ side.
pkgname=fast_matrix_market
pkgdesc="Fast and full-featured Matrix Market I/O library"
pkgver=1.7.6
pkgrel=1
arch=(x86_64)
url="https://github.com/alugowski/${pkgname}"
license=(BSD-2-Clause)
depends=(gcc-libs)
makedepends=(cmake)
optdepends=('eigen' 'blaze' 'armadillo')
source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz)
sha512sums=('e97da2daf76770502e862a13b7b61aaf8797d9bec9d33f182ff28c2a0b3f8e8b078b559643d980d6c7f3ff57da9cf52bde8807120b9373e61851fd57373d51aa')
build() {
cmake \
-S ${pkgname}-${pkgver} \
-B build \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_SHARED_LIBS=TRUE \
-DCMAKE_CXX_STANDARD=17 \
-DFAST_MATRIX_MARKET_BENCH=OFF \
-DFAST_MATRIX_MARKET_TEST=ON \
-DFAST_MATRIX_MARKET_TEST_EXTERNAL_APPS=OFF \
-DFMM_USE_DRAGONBOX=ON \
-DFMM_USE_FAST_FLOAT=ON \
-DFMM_USE_RYU=ON \
-Wno-dev
cmake --build build --target all
}
check() {
ctest --verbose --output-on-failure --test-dir build
}
package() {
DESTDIR="${pkgdir}" cmake --build build --target install
install -Dm 644 ${pkgname}-${pkgver}/LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
rm -r ${pkgdir}/usr/include/{gtest,gmock}
rm -r ${pkgdir}/usr/lib/cmake/GTest
rm -r ${pkgdir}/usr/lib/libgmock*
rm -r ${pkgdir}/usr/lib/libgtest*
rm -r ${pkgdir}/usr/lib/pkgconfig/gmock*
rm -r ${pkgdir}/usr/lib/pkgconfig/gtest*
}
- I expected some file like
/usr/lib/fast_matrix_market.soor/usr/lib/fast_matrix_market.soor/usr/include/fast_matrix_market/fast_matrix_market.hpp, therefore the script will not install fast_matrix_market. - With
-DFAST_MATRIX_MARKET_TEST=ONit will pullgtest, sometimes is nice if user hasgtestinstalled, check ifgtestversion is compatible and try to use, otherwise pull from internet (for examples offline installation could be fail).
- (1) is more important because if user create a C++ program,
#include <fast_matrix_market/fast_matrix_market.hpp>it does not exists with the above installation. - In the video, I am showing that after installation,
gtestfiles are over/usrand we do not like this behavior. Thanks.
I can try help test almost over GitHub action for Windows or Mac.