Open phcerdan opened 3 years ago
Thanks @phcerdan for the link.. it looks like Pablo Arias "Don't do that" example looks pretty similar to the current DGtal setting ;)
Very intersting reading
Thanks @phcerdan for the link.. it looks like Pablo Arias "Don't do that" example looks pretty similar to the current DGtal setting ;)
Hehe a bit, at least now we don't modify CXX_FLAGS
or use global include_directories
, link_libraries
!
The good thing is that the core DGtal (without those dependencies) is indeed relocatable, but some tweaking would be needed if we are interested in shipping DGtal with those extra deps.
DGtal
is not relocatable (the install tree cannot be moved to other computer) when compiled with these dependencies. The installed DGtal target contains full paths to theFoo_INCLUDE_DIRECTORY
and/orFoo_LIBRARIES
, which makes it not relocatable. This is not a problem if we know beforehand where these dependencies will be installed (homebrew, specific OS, etc.) but it is cumberstone to set it up for different platforms.This is an extract of
DGtalLibraryDepends.cmake
(exported targets) of the install tree, showing full paths.The imported targets with the signature
Foo::Foo
are the best solution (CMake docs), but there are packages that don't provide a FooConfig.cmake with FooTargets.cmake. In this case, I think the best solution would be to improve the FindFoo.cmake to create an imported target inside FindFoo.cmake. This approach is done by Kitware/CMake for ZLIB::ZLIB, another HPC user has done it for FFTW3.The current
FindGMP.cmake
(Cairo
,QGLViewer
,Magick++
), would need to be improved to generate imported target GMP::GMP instead of justGMP_INCLUDE_DIR
andGMP_LIBRARIES
.For a short tutorial about this topic and other modern CMake areas: It’s Time To Do CMake Right | Pablo Arias