diff options
author | bfierz <bfierz@users.noreply.github.com> | 2017-09-07 03:50:30 +0300 |
---|---|---|
committer | Neil MacIntosh <neilmac@microsoft.com> | 2017-09-07 03:50:30 +0300 |
commit | b01450878b39307df9abb702f02ce8c1d6c9ee30 (patch) | |
tree | e9613d60767385c19e75eab479ffe106a2f04bed | |
parent | 77e081e88b2a31f803a4e0b5675c79044f97338b (diff) |
Adds an option to disable test generation (#552)
When integrating the GSL as an external dependency, it is usually unnecessary to build and run the unit-tests.
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 986d948..53058e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,12 @@ find_package(Git) # creates a library GSL which is an interface (header files only) add_library(GSL INTERFACE) +# determine whether this is a standalone project or included by other projects +set(GSL_STANDALONE_PROJECT OFF) +if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(GSL_STANDALONE_PROJECT ON) +endif () + # when minimum version required is 3.8.0 remove if below # both branches do exactly the same thing if (CMAKE_MAJOR_VERSION VERSION_LESS 3.7.9) @@ -53,5 +59,8 @@ install( DESTINATION include ) -enable_testing() -add_subdirectory(tests) +option(GSL_TEST "Generate tests." ${GSL_STANDALONE_PROJECT}) +if (GSL_TEST) + enable_testing() + add_subdirectory(tests) +endif () |