cmake: allow to disable building unit tests
This commit introduces a CMake `BUILD_TESTING` boolean option that allows to disable unit tests. This is especially useful in superbuilds where typically only the main library is built. By default, this option is enabled.
This commit is contained in:
parent
7cff62028c
commit
60375e0bd4
@ -31,8 +31,6 @@ option (WITH_THREADS "Enable multithreading support" ON)
|
|||||||
|
|
||||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
include (CMakePackageConfigHelpers)
|
|
||||||
include (CPack)
|
|
||||||
include (CheckCSourceCompiles)
|
include (CheckCSourceCompiles)
|
||||||
include (CheckCXXCompilerFlag)
|
include (CheckCXXCompilerFlag)
|
||||||
include (CheckCXXSourceCompiles)
|
include (CheckCXXSourceCompiles)
|
||||||
@ -43,6 +41,9 @@ include (CheckLibraryExists)
|
|||||||
include (CheckStructHasMember)
|
include (CheckStructHasMember)
|
||||||
include (CheckSymbolExists)
|
include (CheckSymbolExists)
|
||||||
include (CheckTypeSize)
|
include (CheckTypeSize)
|
||||||
|
include (CMakePackageConfigHelpers)
|
||||||
|
include (CPack)
|
||||||
|
include (CTest)
|
||||||
include (DetermineGflagsNamespace)
|
include (DetermineGflagsNamespace)
|
||||||
|
|
||||||
set (CMAKE_THREAD_PREFER_PTHREAD 1)
|
set (CMAKE_THREAD_PREFER_PTHREAD 1)
|
||||||
@ -460,6 +461,7 @@ endif (UNIX OR (APPLE AND HAVE_DLADDR))
|
|||||||
|
|
||||||
# Unit testing
|
# Unit testing
|
||||||
|
|
||||||
|
if (BUILD_TESTING)
|
||||||
add_executable (logging_unittest
|
add_executable (logging_unittest
|
||||||
src/logging_unittest.cc
|
src/logging_unittest.cc
|
||||||
)
|
)
|
||||||
@ -549,6 +551,7 @@ add_test (NAME stl_logging COMMAND stl_logging_unittest)
|
|||||||
if (TARGET symbolize_unittest)
|
if (TARGET symbolize_unittest)
|
||||||
add_test (NAME symbolize COMMAND symbolize_unittest)
|
add_test (NAME symbolize COMMAND symbolize_unittest)
|
||||||
endif (TARGET symbolize_unittest)
|
endif (TARGET symbolize_unittest)
|
||||||
|
endif (BUILD_TESTING)
|
||||||
|
|
||||||
install (TARGETS glog
|
install (TARGETS glog
|
||||||
EXPORT glog-targets
|
EXPORT glog-targets
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user