| 1 | # Building and Installing Cgreen |
| 2 | |
| 3 | Here are your alternatives for installing `Cgreen`. |
| 4 | |
| 5 | ## Install using your distro package manager |
| 6 | |
| 7 | Cgreen is available for [some Linux distros] |
| 8 | (https://repology.org/project/cgreen/versions). If you are on one of |
| 9 | those you can do |
| 10 | |
| 11 | $ sudo apt install cgreen1 |
| 12 | |
| 13 | or equivalent. Not all distros have an up-to-date version. |
| 14 | |
| 15 | |
| 16 | ## Install pre-built binary |
| 17 | |
| 18 | There are occassionally pre-built binaries available from [the GitHub |
| 19 | repo](https://github.com/cgreen-devs/cgreen/releases). You can |
| 20 | download and install these using an appropriate package manager. |
| 21 | |
| 22 | |
| 23 | ## Build from source |
| 24 | |
| 25 | ### Get source and build |
| 26 | |
| 27 | Clone the [`Cgreen` repo](https://github.com/cgreen-devs/cgreen) |
| 28 | |
| 29 | $ git clone https://github.com/cgreen-devs/cgreen |
| 30 | |
| 31 | or get the source from the same place. |
| 32 | |
| 33 | Then build it |
| 34 | |
| 35 | $ cd cgreen |
| 36 | $ make |
| 37 | |
| 38 | The Makefile is mainly for convenience as `Cgreen` is actually built |
| 39 | using `CMake`. So you can tweak the build using normal `CMake` |
| 40 | settings. |
| 41 | |
| 42 | You can run some tests using |
| 43 | |
| 44 | $ make unit |
| 45 | $ make test |
| 46 | |
| 47 | NOTE: to also build the dynamically auto-discovering runner |
| 48 | `cgreen-runner`, which `make unit` uses, you need `binutils` as per |
| 49 | the description in the README.md. |
| 50 | |
| 51 | ### Build options |
| 52 | |
| 53 | You also have some extra options available |
| 54 | |
| 55 | - build with static libraries |
| 56 | - build HTML or PDF documentation |
| 57 | |
| 58 | To enable any of these use the `CMake` graphical user interface (CMakeSetup |
| 59 | on Windows or ccmake on UNIX) to turn these options on or off. |
| 60 | |
| 61 | Note on CYGWIN: Cygwin is not a WIN32 platform, but it is a |
| 62 | DLL-platform where libraries normally goes in the bin directory. Running |
| 63 | the self-tests handles this automatically but if you want to use the binaries |
| 64 | in the 'build'-tree you can either: |
| 65 | |
| 66 | 1) install before running the tests and also set your PATH to include |
| 67 | "/usr/local/lib" |
| 68 | |
| 69 | 2) setting the PATH to include the build directory where the libraries are |
| 70 | there is a sh-compatible command script to do that for you. From the top |
| 71 | of the Cgreen source directory do: |
| 72 | |
| 73 | . cygwin-setup.sh |
| 74 | |
| 75 | ### Use directly |
| 76 | |
| 77 | You can use `Cgreen` from the source tree without actually |
| 78 | installing. Just set your compilation includes to include |
| 79 | `<path_to_cgreen>/include` and link with the built library by pointing |
| 80 | the linker to `<path_to_cgreen>/build/src/` and use `-lcgreen`. E.g. |
| 81 | |
| 82 | $ cc ... -I/home/me/cgreen/include ... |
| 83 | $ cc ... -L/home/me/cgreen/build/src -lcgreen ... |
| 84 | |
| 85 | ### Install |
| 86 | |
| 87 | You can also install `Cgreen` with |
| 88 | |
| 89 | $ make install |
| 90 | |
| 91 | which will install `Cgreen` in what `CMake` considers standard |
| 92 | locations for your environment. Assuming that is `/usr/local` you |
| 93 | should now be able to compile and link using |
| 94 | |
| 95 | $ cc ... -I/usr/local/include ... |
| 96 | $ cc ... -L/usr/local/lib -lcgreen ... |
| 97 |