Commit 0168a129 authored by Henry Schreiner's avatar Henry Schreiner

Merge branch 'testingupdates' into 'master'

Testingupdates

See merge request !7
parents 2ba818e2 a1180227
Pipeline #39088228 passed with stages
in 3 minutes and 10 seconds
......@@ -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
......
......@@ -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»
......
......@@ -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 %}
......
......@@ -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()
```
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment