blob: 2d10c3d610df16a7c6475749bcd2bef4fc641597 [file] [log] [blame]
onqtamb8220c52017-05-16 00:21:15 +03001<!DOCTYPE html>
2<html>
3<title>build-systems</title>
4<xmp theme="united" style="display:none;">
5
6## Build systems
7
8The latest released version of doctest can be obtained from here: https://raw.githubusercontent.com/onqtam/doctest/master/doctest/doctest.h
9
10You 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
17cmake_minimum_required(VERSION 3.0)
18project(cmake_test)
19
20# Prepare doctest for other targets to use
21add_library(doctest INTERFACE)
22target_include_directories(doctest INTERFACE path/to/doctest)
23
24# Make test executable
25add_executable(tests main.cpp)
26target_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
32include(ExternalProject)
33find_package(Git REQUIRED)
34
35ExternalProject_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
48ExternalProject_Get_Property(doctest source_dir)
49set(DOCTEST_INCLUDE_DIR ${source_dir}/doctest CACHE INTERNAL "Path to include folder for doctest")
50```
51
52And later you'll be able to use the doctest include directory like this:
53
54```cmake
55# add it globally
56include_directories(${DOCTEST_INCLUDE_DIR})
57
58# or per target
59target_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
65add_executable(my_tests src_1.cpp src_2.cpp ...)
66target_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>