forked from microsoft/GSL
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.
This commit is contained in:
@@ -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 ()
|
||||
|
Reference in New Issue
Block a user