Skip to content

Commit

Permalink
Merge pull request #1285 from bneumann/master
Browse files Browse the repository at this point in the history
Added installation as external cmake project to README
  • Loading branch information
basvodde committed Mar 16, 2020
2 parents 8f4aa13 + 0fe68e3 commit 7668322
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -196,5 +196,28 @@ There are some scripts that are helpful in creating your initial h, cpp, and
Test files. See scripts/README.TXT
## Integration as external CMake project
Sometimes you want to use CppUTest in your project without installing it to your system or for having control over the version you are using. This little snippet get the wanted version from Github and builds it as a library.
```cmake
# CppUTest
include(FetchContent)
FetchContent_Declare(
CppUTest
GIT_REPOSITORY https://github.com/cpputest/cpputest.git
GIT_TAG v3.8
)
# Set this to ON if you want to have the CppUTests in your project as well.
set(TESTS OFF CACHE BOOL "Switch off CppUTest Test build")
FetchContent_MakeAvailable(CppUTest)
include_directories(${CppUTest_SOURCE_DIR}/include)
```

It can be used then like so:

```cmake
file(GLOB_RECURSE TEST_SOURCES ${TEST_DIR}/*.cpp)
add_executable(run_tests ${TEST_SOURCES})
target_link_libraries(run_tests CppUTest)
```

0 comments on commit 7668322

Please sign in to comment.