6 ms·
The software distribution side of CMake is there and it serves many needs, so you can't really get a clear answer here, because only you know what you really ne
by helloiamsomeone 2y ago
The software distribution side of CMake is there and it serves many needs, so you can't really get a clear answer here, because only you know what you really need.
Package discovery for example can be done with the CMAKE_PREFIX_PATH[1] command line cache variable, which is a list of prefixes where find_*() commands will go looking for things. But if you are putting your own install prefix together, or are using a system prefix, then CMAKE_INSTALL_PREFIX[2] can also serve that purpose and it will also set the default install prefix for cmake --install. You can also control discovery on a per find_*() command basis using various environment and cache variables, all documented in their respective documentation. For example, see the numbered list in find_package's documentation[3].
Setting RPATH can be done at a project level using the CMAKE_INSTALL_RPATH[4] variable. However, if you have both executables and libraries in a project, you might see how that may not be the most useful approach and instead you'd want to reach for CPack scripting (via CPACK_PRE_BUILD_SCRIPTS[5]) to setup RPATH separately for things going in /bin and /lib.
Software distribution is messy and CMake provides tools to deal with things, but you have to know what's the most appropriate soltuion for your case.
[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PA...
[2]: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_P...
[3]: https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure https://cmake.org/cmake/help/latest/command/find_package.htm...
[4]: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_RPATH.html https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_R...
[5]: https://cmake.org/cmake/help/latest/module/CPack.html#variable:CPACK_PRE_BUILD_SCRIPTS https://cmake.org/cmake/help/latest/module/CPack.html#variab...