An Introduction to Modern CMake
cliutils.gitlab.io
cliutils.gitlab.io
https://news.ycombinator.com/item?id=39657703
See the CI workflow using my script here: https://github.com/xrootd/xrootd/blob/master/.github/workflo...
Also, with some advice from Henry I wrote a nice new setup.py for the Python bindings of XRootD integrated with the CMake build. I didn't want a dependency in scikit-build in the end, but his advice helped me a lot.
This is, of course, a massive pain in the ass, but C & C++ library packaging is about twelve different kinds of massive pain in the ass, and CMake is easier to write than a lot of the other packaging formats, so this is a small part of it.
[1] https://cmake.org/cmake/help/latest/command/find_package.htm...
[2] https://cmake.org/cmake/help/latest/module/FindPkgConfig.htm...
[3] https://www.freedesktop.org/wiki/Software/pkg-config/
[4] https://cmake.org/cmake/help/latest/manual/cmake-packages.7....
find_package() is just a souped-up include(). What happens once it finds the script matching the criteria provided by arguments and cache variables depends entirely on the script(s) (plural, because version criterion is satisfied by the *ConfigVersion.cmake script for config mode search) it runs. The PkgConfig module is only mentioned in a couple of CMake provided find modules:
>find -maxdepth 1 -type f -name "Find*.cmake" -not -name FindPkgConfig.cmake -exec ugrep -HFe PkgConfig {} + | cut -d: -f1 | sort | uniq | sed s/..//;s/\.cmake//
FindBLAS
FindCURL
FindCurses
FindEXPAT
FindFontconfig
FindGLUT
FindGSL
FindGnuTLS
FindImageMagick
FindLAPACK
FindLibXml2
FindLibXslt
FindLibinput
FindMPI
FindOpenSP
FindOpenSSL
The prevalent method of discovering packages is via the package provided config scripts, which of course have to come from upstream. Kitware stopped adding new find modules, because they are not worth the maintenance effort (e.g. find modules require maintaining a list of versions like for Python or Boost) and instead upstreams should provide a proper CMake package.pkg-config also really only works in the Linux bubble. CPS[1] is trying to bridge the gap here if you are interested.
Only by going up to the repo listing does one find the actual implementation that alleges to replace pkg-config however <https://github.com/cps-org/cps-config#status> seems like "well, good luck" for the problem they're trying to solve. I mean, they couldn't even write down what does or doesn't work in order to know if I should bother learning its snowflake json schema? Not even a $(cps-config --import) to port over the bazillions of .pc files out in the wild
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_PA...
[2]: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_P...
[3]: https://cmake.org/cmake/help/latest/command/find_package.htm...
[4]: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_R...
[5]: https://cmake.org/cmake/help/latest/module/CPack.html#variab...
--warn-uninitialized and -Werror=dev will do just that: https://cmake.org/cmake/help/latest/manual/cmake.1.html
From a quick glance most of it looks pretty relevant to me.
It's in the official Fedora and Arch repos and there is ppa for Ubuntu
You can always just curl, inspect the script, shell it.
Personally I always use AUR wrappers since I hate having programs installed outside of packages.
The reason why a vocal subcommunity gets hung up on “curl | sh” is that they aren’t comfortable accepting the degree of trust which they’re placing in so many third parties but haven’t fully accepted the implications. Saying “download the file and open it manually” is basically the same as the TSA making you throw out a water bottle – it feels like diligence even though it’s pointless.
This is why most security people are focused on things like pervasive sandboxing to contain the damage when someone makes a mistake, code-signing and revocation, and trusted third-party providers (e.g. a Linux distribution or App Store) which are more trustworthy and can possibly do things like audit every binary they ship.