From 9e6d7bbf004b13860f468298e21221575df9f2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 21 Sep 2018 20:48:18 +0200 Subject: [PATCH] Add documentation for installing Catch from the repository This might prove helpful when the package managers either doesn't have Catch at all, or provides it in obsolete version (Ubuntu 16.04, I am looking at you). Closes #1383 --- docs/cmake-integration.md | 29 ++++++++++++++++++++++++++++- docs/tutorial.md | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md index 5f57c276..a075c040 100644 --- a/docs/cmake-integration.md +++ b/docs/cmake-integration.md @@ -1,6 +1,12 @@ # CMake integration +**Contents**
+[CMake target](#cmake-target)
+[Automatic test registration](#automatic-test-registration)
+[CMake project options](#cmake-project-options)
+[Installing Catch2 from git repository](#installing-catch2-from-git-repository)
+ Because we use CMake to build Catch2, we also provide a couple of integration points for our users. @@ -47,7 +53,7 @@ to your CMake module path. `Catch.cmake` provides function `catch_discover_tests` to get tests from a target. This function works by running the resulting executable with `--list-test-names-only` flag, and then parsing the output to find all -existing tests. +existing tests. #### Usage ```cmake @@ -184,6 +190,27 @@ included in the installation. Defaults to `ON`. * `BUILD_TESTING` -- When `ON` and the project is not used as a subproject, Catch2's test binary will be built. Defaults to `ON`. + +## Installing Catch2 from git repository + +If you cannot install Catch2 from a package manager (e.g. Ubuntu 16.04 +provides catch only in version 1.2.0) you might want to install it from +the repository instead. Assuming you have enough rights, you can just +install it to the default location, like so: +``` +$ git clone https://github.com/catchorg/Catch2.git +$ cd Catch2 +$ cmake -Bbuild -H. -DBUILD_TESTING=OFF +$ sudo cmake --build build/ --target install +``` + +If you do not have superuser rights, you will also need to specify +[CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) +when configuring the build, and then modify your calls to +[find_package](https://cmake.org/cmake/help/latest/command/find_package.html) +accordingly. + + --- [Home](Readme.md#top) diff --git a/docs/tutorial.md b/docs/tutorial.md index b0c2bc88..387a250a 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -15,7 +15,7 @@ The simplest way to get Catch2 is to download the latest [single header version](https://raw.githubusercontent.com/catchorg/Catch2/master/single_include/catch2/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file. Alternative ways of getting Catch2 include using your system package -manager, or installing it using its CMake package. +manager, or installing it using [its CMake package](cmake-integration.md#installing-catch2-from-git-repository). The full source for Catch2, including test projects, documentation, and other things, is hosted on GitHub. [http://catch-lib.net](http://catch-lib.net) will redirect you there.