Simplify the boilerplate code of CPM.
The goal of this patch is to reduce the boiler-plate code necessary to include CPM in a project.
I'm all for reducing this boilerplate overhead. Earlier, we had a contributor propose something similar to this that now exists as cpm/util/init-cpm-module.cmake and cpm/util/init-cpm.cmake.
My primary concern is adding an extra indirection that requires two steps (if the form of download and reference) instead of copying code from a webpage directly into your CMake project file. The ideal method would be to package CPM alongside the CMake distribution, but I haven't been investigating that possibility actively.
Here's what I propose: we explain both methods in the readme file and we include this CMake file in the root CPM directory. In the readme, we prioritize the copy-and-paste method above the 2 step download and reference method.
Since this request is occurring often, there's clearly some need to be filled here. I'm open to suggestions.
My main concern is that CPM can be made easier to understand. I think CPM's landing page should explain its workflow and not a detailed example.
My inspiration comes from Homebrew, and I would divide the CPM workflow into 3 steps: download, setup and search; see below for the mockup. Each of these steps is small, understandable, and simpler. In contrast, the current situation resorts to copy/paste bits of boiler-plate code situated in the middle of the landing page (after the TOC).
Additionally, I think the README.md should be reduced. I would even ask you to move everything after the table-of-contents into a wiki. There is a lot of very useful information, but is hard to navigate.
1. Download CPM
Download init-cpm.cmake into your main directory
$ wget https://github.com/iauns/cpm/blob/master/util/init-cpm.cmake
2. Setup CPM
include(init-cpm.cmake) # download and initialize CPM
# TODO: Include any modules here...
CPM_Finish()
3. Search for packages
http://www.cpm.rocks/
4. Learn
In our wiki you can learn:
- a brief example on using CPM
- developing your own modules
- ...
Thanks for the excellent feedback. The readme page does contain too much information and should be condensed. I'm planning on simplifying and revamping the readme page at the very least. I'm also swayed by your argument for download and setup; your solution is more similar to the ideal solution where CPM is packaged alongside CMake. After trying it out, it also makes CPM projects less noisy.