-
Notifications
You must be signed in to change notification settings - Fork 6
Description
In
Lines 86 to 87 in fec7c42
| target_link_libraries (cprnc | |
| PUBLIC ${NetCDF_Fortran_LIBRARIES} ${NetCDF_C_LIBRARIES} ${NetCDF_LIBRARIES}) |
The NetCDF_*LIBRARIES variables are strings of linker flags -L<path> -l<lib>.
But target_link_libraries expects full paths to libraries like <path>/lib<lib>.so, otherwise CMake does not know what libraries are effectively being linked.
So even though the build works fine, features like CMAKE_INSTALL_RPATH_USE_LINK_PATH=ON do not work, because <path> is not among the known link directories.
Instead of using nc-config --libs, you could use pkg-config, for which CMake has builtin support:
https://cmake.org/cmake/help/latest/module/FindPkgConfig.html
In particular pkg_search_module would then give you *_LIBRARIES which is a list of full paths, which can be used in target_link_libraries, so that CMAKE_INSTALL_RPATH_USE_LINK_PATH=ON works again.