diff options
| author | Thijs Paelman <thijs@ouroboros.rocks> | 2025-11-06 01:18:12 +0100 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2025-11-07 08:36:30 +0100 |
| commit | fdaef7a50cfc7342b99577cec124f1a93c003bdd (patch) | |
| tree | 06289cce94628a1eb8330dcc1f2bcc790638606e | |
| parent | 535fba02cd27020f9c64dcbe4e97584a145816d4 (diff) | |
| download | ouroboros-fdaef7a50cfc7342b99577cec124f1a93c003bdd.tar.gz ouroboros-fdaef7a50cfc7342b99577cec124f1a93c003bdd.zip | |
build: Only enable tests for the project itself
Only enable testing when this project itself is build, not when it is
included in another project, hence the extra CMAKE_PROJECT_NAME
condition.
https://cliutils.gitlab.io/modern-cmake/chapters/testing.html
Signed-off-by: Thijs Paelman <thijs@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
| -rw-r--r-- | CMakeLists.txt | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cd2bffee..b5632ad9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,9 +180,12 @@ else () endif() include(CTest) # Sets BUILD_TESTING by default to on. -# BUILD_TESTS: control if tests are included by CMAKE. -# Can depend on more than only BUILD_TESTING in the future. -set(BUILD_TESTS ${BUILD_TESTING}) +# BUILD_TESTS: control if tests are included by CMAKE for this project. +if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + set(BUILD_TESTS ON) +else () + set(BUILD_TESTS OFF) +endif() add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) find_package(ProtobufC QUIET) |
