1
0
mirror of synced 2024-12-22 12:40:00 +01:00

Merge branch 'henryiii/chore/bump' into 'master'

chore: bump to 3.20.5

Closes #43

See merge request CLIUtils/modern-cmake!52
This commit is contained in:
Henry Schreiner 2021-06-24 16:14:42 +00:00
commit c78a745ba3
8 changed files with 41 additions and 10 deletions

View File

@ -1,5 +1,5 @@
[bumpversion] [bumpversion]
current_version = 3.20.0 current_version = 3.20.5
[bumpversion:file:.gitlab-ci.yml] [bumpversion:file:.gitlab-ci.yml]
search = cmake-{current_version}-linux search = cmake-{current_version}-linux

View File

@ -5,7 +5,7 @@ test_code:
- apt-get update && apt-get install -y make cmake libboost-dev git - apt-get update && apt-get install -y make cmake libboost-dev git
# We will install latest CMake, even though Ubuntu has a recent one # We will install latest CMake, even though Ubuntu has a recent one
- mkdir -p $HOME/.local - mkdir -p $HOME/.local
- curl -s "https://cmake.org/files/v3.20/cmake-3.20.0-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local - curl -s "https://cmake.org/files/v3.20/cmake-3.20.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local
- export PATH=$HOME/.local/bin:$PATH - export PATH=$HOME/.local/bin:$PATH
script: script:
- cmake -S examples -B build - cmake -S examples -B build

View File

@ -34,13 +34,13 @@ You can [download CMake from KitWare][download]. This is how you will probably g
On Linux, there are several options. Kitware provides a [Debian/Ubunutu apt repository][apt], as well as [snap packages][snap]. There are universal Linux binaries provided, but you'll need to pick an install location. If you already use `~/.local` for user-space packages, the following single line command[^1] will get CMake for you [^2]: On Linux, there are several options. Kitware provides a [Debian/Ubunutu apt repository][apt], as well as [snap packages][snap]. There are universal Linux binaries provided, but you'll need to pick an install location. If you already use `~/.local` for user-space packages, the following single line command[^1] will get CMake for you [^2]:
{% term %} {% term %}
~ $ wget -qO- "https://cmake.org/files/v3.20/cmake-3.20.0-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local ~ $ wget -qO- "https://cmake.org/files/v3.20/cmake-3.20.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local
{% endterm %} {% endterm %}
The names changed in 3.20; older releases had names like `cmake-3.19.7-Linux-x86_64.tar.gz`. If you just want a local folder with CMake only: The names changed in 3.20; older releases had names like `cmake-3.19.7-Linux-x86_64.tar.gz`. If you just want a local folder with CMake only:
{% term %} {% term %}
~ $ mkdir -p cmake-3.20 && wget -qO- "https://cmake.org/files/v3.20/cmake-3.20.0-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.20 ~ $ mkdir -p cmake-3.20 && wget -qO- "https://cmake.org/files/v3.20/cmake-3.20.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.20
~ $ export PATH=`pwd`/cmake-3.20/bin:$PATH ~ $ export PATH=`pwd`/cmake-3.20/bin:$PATH
{% endterm %} {% endterm %}
@ -49,7 +49,7 @@ You'll obviously want to append to the PATH every time you start a new terminal,
And, if you want a system install, install to `/usr/local`; this is an excellent choice in a Docker container, for example on GitLab CI. Do not try it on a non-containerized system. And, if you want a system install, install to `/usr/local`; this is an excellent choice in a Docker container, for example on GitLab CI. Do not try it on a non-containerized system.
{% term %} {% term %}
docker $ wget -qO- "https://cmake.org/files/v3.20/cmake-3.20.0-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local docker $ wget -qO- "https://cmake.org/files/v3.20/cmake-3.20.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
{% endterm %} {% endterm %}

View File

@ -14,7 +14,7 @@ For example, to download Catch2:
FetchContent_Declare( FetchContent_Declare(
catch catch
GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.0 GIT_TAG v2.13.6
) )
# CMake 3.14+ # CMake 3.14+

View File

@ -1,13 +1,42 @@
# Catch # Catch
Catch and [Catch2] (C++11 only version) are powerful, idomatic testing solutions similar in philosophy to PyTest for Python. To use Catch in a CMake project, there are several options. [Catch2] (C++11 only version) is a powerful, idomatic testing solutions similar in philosophy to PyTest for Python. It supports a wider range of compilers than GTest, and is quick to support new things, like M1 builds on macOS. It also has a smaller but faster twin, [doctest](https://github.com/onqtam/doctest), which is quick to compile but misses features like matchers. To use Catch in a CMake project, there are several options.
## Configure methods
Catch has nice CMake support, though to use it, you need the full repo. This could be with submodules or FetchContent. Both the [`extended-project`](https://gitlab.com/CLIUtils/modern-cmake/-/tree/master/examples/extended-project) and [`fetch`](https://gitlab.com/CLIUtils/modern-cmake/-/tree/master/examples/fetch) examples use FetchContent. See [the docs](https://github.com/catchorg/Catch2/blob/v2.x/docs/cmake-integration.md#top).
## Quick download
This is likely the simplest method and supports older versions of CMake. You can download the all-in-one header file in one step:
```cmake
add_library(catch_main main.cpp)
target_include_directories(catch_main PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
set(url https://github.com/philsquared/Catch/releases/download/v2.13.6/catch.hpp)
file(
DOWNLOAD ${url} "${CMAKE_CURRENT_BINARY_DIR}/catch.hpp"
STATUS status
EXPECTED_HASH SHA256=681e7505a50887c9085539e5135794fc8f66d8e5de28eadf13a30978627b0f47)
list(GET status 0 error)
if(error)
message(FATAL_ERROR "Could not download ${url}")
endif()
target_include_directories(catch_main PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
```
This will two downloads when Catch 3 is released, as that now requires two files (but you no longer have to write a main.cpp). The `main.cpp` looks like this:
```cpp
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
```
## Vendoring ## Vendoring
If you simply drop in the single include release of Catch into your project, this is what you would need to add Catch: If you simply drop in the single include release of Catch into your project, this is what you would need to add Catch:
```cmake ```cmake
# Prepare "Catch" library for other executables # Prepare "Catch" library for other executables
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/catch) set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/catch)

View File

@ -1,5 +1,7 @@
# GoogleTest # GoogleTest
GoogleTest and GoogleMock are classic options; personally, I personally would recommend Catch2 instead, as GoogleTest heavily follows the Google development philosophy; it drops old compilers very quickly, it assumes users want to live at HEAD, etc. Adding GoogleMock is also often painful - and you need GoogleMock to get matchers, which are a default feature in Catch2 (but not doctest).
## Submodule method (preferred) ## Submodule method (preferred)
To use this method, just checkout GoogleTest as a submodule:[^1] To use this method, just checkout GoogleTest as a submodule:[^1]

View File

@ -2,7 +2,7 @@
FetchContent_Declare( FetchContent_Declare(
catch catch
GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.9.1) GIT_TAG v2.13.6)
FetchContent_MakeAvailable(catch) FetchContent_MakeAvailable(catch)
# Adds Catch2::Catch2 # Adds Catch2::Catch2

View File

@ -8,7 +8,7 @@ include(CTest)
FetchContent_Declare( FetchContent_Declare(
catch catch
GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.0) GIT_TAG v2.13.6)
# CMake 3.14+ # CMake 3.14+
FetchContent_MakeAvailable(catch) FetchContent_MakeAvailable(catch)