Once CMake has successfully built an executable which requires some shared libraries, by using 'ldd', we can easily get the list of shared library dependencies and where we can find them.
For instance, libstdc++
is here: /usr/lib64/libstdc++.so.6
Now we want to make a package (e.g. a .tgz package), we need to include those shared libraries with no doubt.
We can do:
set(DEPENDENCIES /usr/lib64/libstdc++.so.6 /usr/lib64/[libname2] /usr/lib64/[libname3])
foreach(DEPENDENCY ${DEPENDENCIES})
install(PROGRAMS "${DEPENDENCY}" DESTINATION lib)
endforeach()
Is there a smarter way to achieve the same purpose?
Instead of manually specifying path to all libraries, can we make it an automatic process? Given CMake already knows all the dependencies and the according library path in the link stage, should it be straightforward?