MATAR icon indicating copy to clipboard operation
MATAR copied to clipboard

Upgrade MATAR CMake build system to use targets

Open raovgarimella opened this issue 2 years ago • 0 comments

This PR upgrades MATAR's CMake build system to use CMake Targets which set up transitive dependencies and allow easy linking of other projects to MATAR. This PR also writes out a lib/cmake/matarConfig.cmake file that other projects can use to find out what dependencies MATAR was built with and what libraries it should link to. Otherwise, you have to remember that MATAR was built with Kokkos + CUDA and specify the path to Kokkos and CUDA in a third party app that uses Kokkos. It gets ugly very fast.

There are many tutorials on modern CMake but I found this one to be most instructive (first 30-40 mins). https://www.youtube.com/watch?v=bsXLMQ6WgIk If you choose a different one to read/watch make sure it covers the topics of targets, transitive dependencies, importing and exporting targets and config files.

I am happy to tweak variable names etc to suit everyone's taste. I opted for verbose names to avoid clashing with variables that other packages in a large build system might make. Someone might set an environment variable KOKKOS=OFF and MATAR uses that variable which is dangerous. With a variable called MATAR_ENABLE_KOKKOS it is clear what is being set.

raovgarimella avatar Jun 22 '22 16:06 raovgarimella