feltor icon indicating copy to clipboard operation
feltor copied to clipboard

Provide cmake install rules

Open mwiesenberger opened this issue 8 months ago • 1 comments

Currently, the dg library and its components have to be used using FetchContent or CPM by downstream users in their cmake files because we do not provide install rules. If we provide install rules in our CMakeLists.txt then users can install the library and use find_package( feltor REQUIRED) instead, which would open up the way to interoperate with external package managers like vcpkg, conan or spack.

The problem here is that the dg-library is header-only but it can be configured multiple ways (for GPU, CPU, ...) which incur different dependencies and compile options associated with the feltor::dg targets (specifically, when compiling for CUDA we need to link -lcusparse and set cuda compile options). The default installation rules following the cmake tutorial https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html hard-bake the choice of the configuration options into the installed targets so a user of find_package can no longer decide to use GPU vs CPU say. The nvidia/cccl library somehow manages to do exactly what we want here but it is difficult to see exactly how to reproduce this feature

See this discussion https://discourse.cmake.org/t/how-to-write-a-configurable-import-target/14197 for details

mwiesenberger avatar Jun 04 '25 13:06 mwiesenberger

This issue may be related https://gitlab.kitware.com/cmake/cmake/-/issues/26894

mwiesenberger avatar Jun 11 '25 08:06 mwiesenberger