Lines Matching +full:ubuntu +full:- +full:cmake +full:- +full:tests
2 # CMake integration
5 [CMake target](#cmake-target)<br>
6 [Automatic test registration](#automatic-test-registration)<br>
7 [CMake project options](#cmake-project-options)<br>
8 [Installing Catch2 from git repository](#installing-catch2-from-git-repository)<br>
10 Because we use CMake to build Catch2, we also provide a couple of
13 1) Catch2 exports a (namespaced) CMake target
14 2) Catch2's repository contains CMake scripts for automatic registration
17 ## CMake target
19 Catch2's CMake build exports an interface target `Catch2::Catch2`. Linking
25 ```cmake
27 target_link_libraries(tests Catch2::Catch2)
33 ```cmake
35 target_link_libraries(tests Catch2::Catch2)
40 Catch2's repository also contains two CMake scripts that help users
44 1) `Catch.cmake` (and its dependency `CatchAddTests.cmake`)
45 2) `ParseAndAddCatchTests.cmake`
49 to your CMake module path.
51 ### `Catch.cmake` and `CatchAddTests.cmake`
53 `Catch.cmake` provides function `catch_discover_tests` to get tests from
55 `--list-test-names-only` flag, and then parsing the output to find all
56 existing tests.
59 ```cmake
76 ```cmake
91 pass to the Catch executable alongside the `--list-test-names-only` flag.
120 Specifies additional properties to be set on all tests discovered by this
126 Make the list of tests available in the variable `var`, rather than the
132 ### `ParseAndAddCatchTests.cmake`
137 commented-out tests will be registered anyway.
142 ```cmake
160 * `PARSE_CATCH_TESTS_VERBOSE` -- When `ON`, the script prints debug
162 * `PARSE_CATCH_TESTS_NO_HIDDEN_TESTS` -- When `ON`, hidden tests (tests
165 * `PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME` -- When `ON`, adds fixture
167 * `PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME` -- When `ON`, adds target
169 * `PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS` -- When `ON`, adds test
170 file to `CMAKE_CONFIGURE_DEPENDS`. This means that the CMake configuration
171 step will be re-ran when the test files change, letting new tests be
175 Optionally, one can specify a launching command to run tests by setting the
177 instance to run some tests using `MPI` and other sequentially, one can write
178 ```cmake
185 ## CMake project options
187 Catch2's CMake project also provides some options for other projects
190 * `CATCH_BUILD_TESTING` -- When `ON`, Catch2's SelfTest project will be
191 built. Defaults to `ON`. Note that Catch2 also obeys `BUILD_TESTING` CMake
194 * `CATCH_BUILD_EXAMPLES` -- When `ON`, Catch2's usage examples will be
196 * `CATCH_INSTALL_DOCS` -- When `ON`, Catch2's documentation will be
198 * `CATCH_INSTALL_HELPERS` -- When `ON`, Catch2's contrib folder will be
200 * `BUILD_TESTING` -- When `ON` and the project is not used as a subproject,
206 If you cannot install Catch2 from a package manager (e.g. Ubuntu 16.04
213 $ cmake -Bbuild -H. -DBUILD_TESTING=OFF
214 $ sudo cmake --build build/ --target install
218 [CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html)
220 [find_package](https://cmake.org/cmake/help/latest/command/find_package.html)
224 ---