|
| 1 | +# [≡](#contents) [C++ submodule manager command-line interface](#) [](https://travis-ci.org/cppsm/cppsm-cli) |
| 2 | + |
| 3 | +Poor man's submodule management, build scripts, and CI integration for simple, |
| 4 | +"conventional" C++ libraries, executable tests, and executable programs on top |
| 5 | +of |
| 6 | + |
| 7 | +- [CMake](https://cmake.org/), |
| 8 | +- [git](https://git-scm.com/), and |
| 9 | +- [Travis CI](https://travis-ci.org/). |
| 10 | + |
| 11 | +The idea is to minimize boilerplate by relying on simple conventions over |
| 12 | +excessive configuration. See also the |
| 13 | +[C++ submodule manager boilerplate](https://github.com/cppsm/cppsm-boilerplate) |
| 14 | +project. |
| 15 | + |
| 16 | +## <a id="contents"></a> [≡](#contents) [Contents](#contents) |
| 17 | + |
| 18 | +- [Synopsis](#synopsis) |
| 19 | +- [Project structure](#project-structure) |
| 20 | + |
| 21 | +## <a id="synopsis"></a> [≡](#contents) [Synopsis](#synopsis) |
| 22 | + |
| 23 | +Create a new project: |
| 24 | + |
| 25 | +```bash |
| 26 | +mkdir PROJECT && cd "$_" |
| 27 | +git init |
| 28 | +cppsm init |
| 29 | +``` |
| 30 | + |
| 31 | +Try the hello world example (after `init`): |
| 32 | + |
| 33 | +```bash |
| 34 | +cppsm hello |
| 35 | +cppsm test |
| 36 | +.build*/internals/hello |
| 37 | +``` |
| 38 | + |
| 39 | +Start hacking: |
| 40 | + |
| 41 | +```bash |
| 42 | +emacs internals/program/hello.cpp & |
| 43 | +cppsm test-watch |
| 44 | +``` |
| 45 | + |
| 46 | +Clone an existing project: |
| 47 | + |
| 48 | +```bash |
| 49 | +git clone URI |
| 50 | +git submodule update --init # NOTE: non-recursive |
| 51 | +``` |
| 52 | + |
| 53 | +Add a required library: |
| 54 | + |
| 55 | +```bash |
| 56 | +cppsm add requires URL/NAME.git BRANCH |
| 57 | +``` |
| 58 | + |
| 59 | +Remove a previously required library: |
| 60 | + |
| 61 | +```bash |
| 62 | +cppsm remove requires/NAME/BRANCH |
| 63 | +``` |
| 64 | + |
| 65 | +Update all required libraries: |
| 66 | + |
| 67 | +```bash |
| 68 | +cppsm update-all |
| 69 | +``` |
| 70 | + |
| 71 | +## <a id="project-structure"></a> [≡](#contents) [Project structure](#project-structure) |
| 72 | + |
| 73 | +At the root of a project there are three directories as follows: |
| 74 | + |
| 75 | +- The `equipment` directory may contain any number of _project submodules_ that |
| 76 | + the project internally depends upon. |
| 77 | +- The `internals` directory may contain one or more _target directories_ that |
| 78 | + are internal to the project. |
| 79 | +- The `provides` directory may contain one or more _target directories_ that are |
| 80 | + provided for dependant projects. |
| 81 | +- The `requires` directory may contain any number of _project submodules_ that |
| 82 | + the provided targets depend upon. |
| 83 | + |
| 84 | +In other words, both `internals` and `provides` may contain one or more target |
| 85 | +directories. In case only a single `internal` or `provides` target directory is |
| 86 | +needed, there is no need to create a nested directory. |
| 87 | + |
| 88 | +A single _target directory_ may simultaneously contain |
| 89 | + |
| 90 | +- a library in the `include/${name}` and `library` directories, |
| 91 | +- an executable test in the `testing` directory, and |
| 92 | +- an executable program in the `program` directory. |
| 93 | + |
| 94 | +Try the `cppsm hello` script. It generates a simple example project that has |
| 95 | +essentially the following structure: |
| 96 | + |
| 97 | + CMakeLists.txt |
| 98 | + equipment/ |
| 99 | + testing.cpp/ |
| 100 | + v1/ |
| 101 | + provides/ |
| 102 | + CMakeLists.txt |
| 103 | + include/ |
| 104 | + testing_v1/ |
| 105 | + test_synopsis.hpp |
| 106 | + test.hpp |
| 107 | + library/ |
| 108 | + test.cpp |
| 109 | + internals/ |
| 110 | + CMakeLists.txt |
| 111 | + testing/ |
| 112 | + message_test.cpp |
| 113 | + program/ |
| 114 | + hello.cpp |
| 115 | + provides/ |
| 116 | + CMakeLists.txt |
| 117 | + include/ |
| 118 | + message_v1/ |
| 119 | + hello.hpp |
| 120 | + library/ |
| 121 | + hello.cpp |
| 122 | + |
| 123 | +Note that the include directories are versioned as are CMake target names and |
| 124 | +C++ namespace names. This allows multiple major versions of a library to be used |
| 125 | +simultaneously. |
0 commit comments