1
0
mirror of synced 2024-11-05 04:28:54 +01:00

Merge branch 'testingupdates' into 'master'

Testingupdates

See merge request CLIUtils/modern-cmake!7
This commit is contained in:
Henry Schreiner 2018-12-05 18:21:01 +00:00
commit 0168a1297a
5 changed files with 14 additions and 5 deletions

View File

@ -4,7 +4,7 @@ test_code:
stage: test
before_script:
- mkdir -p $HOME/.local
- curl -s "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local
- curl -s "https://cmake.org/files/v3.13/cmake-3.13.1-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local
- export PATH=$HOME/.local/bin:$PATH
script:
- mkdir -p build

View File

@ -26,6 +26,9 @@ if(NOT BUILD_TESTS_DEFAULT)
mark_as_advanced(BUILD_TESTS)
endif()
```
Note that `BUILD_TESTING` is a better way to check for testing being enabled if you use `include(CTest)`, since it is defined for you. This is just an example of `CMakeDependentOption`.
## «module:CMakePrintHelpers»

View File

@ -13,13 +13,13 @@ You can [download CMake from KitWare][cmake-download]. This is how you'll probab
On Linux, there are 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 %}
~ $ wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local
~ $ wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.1-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local
{% endterm %}
If you just want a local folder with CMake only:
{% term %}
~ $ mkdir -p cmake-3.13 && wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.13
~ $ mkdir -p cmake-3.13 && wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.1-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.13
~ $ export PATH=`pwd`/cmake-3.13/bin:$PATH
{% endterm %}
@ -28,7 +28,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.
{% term %}
docker $ wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
docker $ wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.1-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
{% endterm %}

View File

@ -4,6 +4,12 @@
In your main CMakeLists.txt you need to add the following function call (not in a subfolder):
```cmake
include(CTest)
```
Which will enable testing and set a `BUILD_TESTING` option so users can turn testing on and off (Along with [a few other things](https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/CTest.cmake)). Or you can do this yourself:
```cmake
enable_testing()
```

View File

@ -51,7 +51,7 @@ Then, to add a test, I'd recommend the following macro:
macro(package_add_test TESTNAME)
add_executable(${TESTNAME} ${ARGN})
target_link_libraries(${TESTNAME} gtest gmock gtest_main)
add_test(${TESTNAME} ${TESTNAME})
add_test(${TESTNAME} COMMAND ${TESTNAME})
set_target_properties(${TESTNAME} PROPERTIES FOLDER tests)
endmacro()