onqtam | b8220c5 | 2017-05-16 00:21:15 +0300 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <title>build-systems</title> |
| 4 | <xmp theme="united" style="display:none;"> |
| 5 | |
| 6 | ## Build systems |
| 7 | |
| 8 | The latest released version of doctest can be obtained from here: https://raw.githubusercontent.com/onqtam/doctest/master/doctest/doctest.h |
| 9 | |
| 10 | You can substitute ```master``` with ```dev``` or a tag like ```1.2.0``` for a specific version in the URL above. |
| 11 | |
| 12 | ### CMake |
| 13 | |
| 14 | - **doctest** is easiest to use as a single file inside your own repository. Then the following minimal example will work: |
| 15 | |
| 16 | ```cmake |
| 17 | cmake_minimum_required(VERSION 3.0) |
| 18 | project(cmake_test) |
| 19 | |
| 20 | # Prepare doctest for other targets to use |
| 21 | add_library(doctest INTERFACE) |
| 22 | target_include_directories(doctest INTERFACE path/to/doctest) |
| 23 | |
| 24 | # Make test executable |
| 25 | add_executable(tests main.cpp) |
| 26 | target_link_libraries(tests doctest) |
| 27 | ``` |
| 28 | |
| 29 | - You can also use the following CMake snippet to automatically fetch the entire **doctest** repository from github and configure it as an external project: |
| 30 | |
| 31 | ```cmake |
| 32 | include(ExternalProject) |
| 33 | find_package(Git REQUIRED) |
| 34 | |
| 35 | ExternalProject_Add( |
| 36 | doctest |
| 37 | PREFIX ${CMAKE_BINARY_DIR}/doctest |
| 38 | GIT_REPOSITORY https://github.com/onqtam/doctest.git |
| 39 | TIMEOUT 10 |
| 40 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull |
| 41 | CONFIGURE_COMMAND "" |
| 42 | BUILD_COMMAND "" |
| 43 | INSTALL_COMMAND "" |
| 44 | LOG_DOWNLOAD ON |
| 45 | ) |
| 46 | |
| 47 | # Expose required variable (DOCTEST_INCLUDE_DIR) to parent scope |
| 48 | ExternalProject_Get_Property(doctest source_dir) |
| 49 | set(DOCTEST_INCLUDE_DIR ${source_dir}/doctest CACHE INTERNAL "Path to include folder for doctest") |
| 50 | ``` |
| 51 | |
| 52 | And later you'll be able to use the doctest include directory like this: |
| 53 | |
| 54 | ```cmake |
| 55 | # add it globally |
| 56 | include_directories(${DOCTEST_INCLUDE_DIR}) |
| 57 | |
| 58 | # or per target |
| 59 | target_include_directories(my_target PUBLIC ${DOCTEST_INCLUDE_DIR}) |
| 60 | ``` |
| 61 | |
| 62 | - If you have the entire doctest repository available (as a submodule or just as files) you could also include it in your CMake build by using ```add_subdirectory(path/to/doctest)``` and then you could use it like this: |
| 63 | |
| 64 | ```cmake |
| 65 | add_executable(my_tests src_1.cpp src_2.cpp ...) |
| 66 | target_link_libraries(my_tests doctest) |
| 67 | ``` |
| 68 | |
| 69 | - The ```CMakeLists.txt``` file of the doctest repository has ```install()``` commands so you could also use doctest as a package. |
| 70 | |
| 71 | ### Package managers |
| 72 | |
| 73 | **doctest** is available through the following package managers: |
| 74 | |
| 75 | - vcpkg |
| 76 | - hunter |
| 77 | - conan |
| 78 | |
| 79 | --- |
| 80 | |
| 81 | [Home](readme.html#reference) |
| 82 | |
| 83 | |
| 84 | </xmp> |
| 85 | <script src="strapdown.js/strapdown.js"></script> |
| 86 | </html> |