cmake: not build ctest binaries as default

unit test binaries are disabled by default now.
To enable it use either

cmake -DUNITTEST=1 ..

or

cmake -DCMAKE_BUILD_TYPE=DEBUG

where CMAKE_BUILD_TYPE must be different from "RELEASE"
see https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html
This commit is contained in:
Davide Gerhard 2019-11-12 14:28:29 +01:00
parent 8fd4bebf45
commit 1ab26c66e2
No known key found for this signature in database
GPG Key ID: 7CBEFA144857DC97
1 changed files with 14 additions and 3 deletions

View File

@ -13,6 +13,7 @@ option(FORCE_SSE "Compile with SSE instruction only" OFF)
option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF) option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF)
option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF) option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF)
option(OPTIONAL_TEST "Compile optional test (might be broken)" OFF) option(OPTIONAL_TEST "Compile optional test (might be broken)" OFF)
# UNITTEST option must be after CMAKE_BUILT_TYPE
# where cmake find custom modules # where cmake find custom modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
@ -88,6 +89,13 @@ endif()
message(STATUS "Build type set to: ${CMAKE_BUILD_TYPE}") message(STATUS "Build type set to: ${CMAKE_BUILD_TYPE}")
message("CMake system: ${CMAKE_SYSTEM_NAME}") message("CMake system: ${CMAKE_SYSTEM_NAME}")
# Unittest should be on for dev builds and off for releases.
if(CMAKE_BUILD_TYPE MATCHES "Release")
option(UNITTEST "Build unittest binaries." OFF)
else()
option(UNITTEST "Build unittest binaries." ON)
endif()
# set compiler # set compiler
include(FindCompiler) include(FindCompiler)
@ -202,9 +210,12 @@ add_subdirectory(${CUSTOM_MISC_DIR})
add_subdirectory(src) add_subdirectory(src)
# ctest # ctest
if(UNITTEST)
message(STATUS "Build unit test binaries")
include(CTest) include(CTest)
enable_testing() enable_testing()
add_subdirectory(test) add_subdirectory(test)
endif(UNITTEST)
# manage scripts # manage scripts
add_subdirectory(scripts) add_subdirectory(scripts)