Add BUILD_TESTS option to CMake build.

This commit is contained in:
James Benton 2020-05-12 15:23:31 +01:00 committed by Ilya Lipnitskiy
parent 56b8d915be
commit e01b30d4fe

View File

@ -12,6 +12,11 @@ PROJECT(protobuf-c)
option(MSVC_STATIC_BUILD "MSVC_STATIC_BUILD" OFF) option(MSVC_STATIC_BUILD "MSVC_STATIC_BUILD" OFF)
option(BUILD_PROTO3 "BUILD_PROTO3" ON) option(BUILD_PROTO3 "BUILD_PROTO3" ON)
option(BUILD_PROTOC "Build protoc-gen-c" ON) option(BUILD_PROTOC "Build protoc-gen-c" ON)
if(CMAKE_BUILD_TYPE MATCHES Debug)
option(BUILD_TESTS "Build tests" ON)
else()
option(BUILD_TESTS "Build tests" OFF)
endif()
INCLUDE(TestBigEndian) INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN) TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
@ -94,7 +99,7 @@ FUNCTION(GENERATE_TEST_SOURCES PROTO_FILE SRC HDR)
ENDFUNCTION() ENDFUNCTION()
IF(CMAKE_BUILD_TYPE MATCHES Debug) IF(BUILD_TESTS)
ENABLE_TESTING() ENABLE_TESTING()
GENERATE_TEST_SOURCES(${TEST_DIR}/test.proto t/test.pb-c.c t/test.pb-c.h) GENERATE_TEST_SOURCES(${TEST_DIR}/test.proto t/test.pb-c.c t/test.pb-c.h)