Make test suite optional by using CTest

This commit is contained in:
David Seifert 2017-04-28 22:46:52 +02:00
parent 5a5699bdbd
commit 8f824265ea
3 changed files with 83 additions and 76 deletions

View File

@ -15,6 +15,9 @@ option(ENABLE_HLSL "Enables HLSL input support" ON)
project(glslang) project(glslang)
# make testing optional
include(CTest)
if(ENABLE_AMD_EXTENSIONS) if(ENABLE_AMD_EXTENSIONS)
add_definitions(-DAMD_EXTENSIONS) add_definitions(-DAMD_EXTENSIONS)
endif(ENABLE_AMD_EXTENSIONS) endif(ENABLE_AMD_EXTENSIONS)

View File

@ -1,9 +1,10 @@
# Suppress all warnings from external projects. # Suppress all warnings from external projects.
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w) set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)
if (TARGET gmock) if(BUILD_TESTING)
if(TARGET gmock)
message(STATUS "Google Mock already configured - use it") message(STATUS "Google Mock already configured - use it")
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest) elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
# We need to make sure Google Test does not mess up with the # We need to make sure Google Test does not mess up with the
# global CRT settings on Windows. # global CRT settings on Windows.
if(WIN32) if(WIN32)
@ -27,7 +28,8 @@ elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
gtest_disable_pthreads gtest_disable_pthreads
gtest_force_shared_crt gtest_force_shared_crt
gtest_hide_internal_symbols) gtest_hide_internal_symbols)
else() else()
message(STATUS message(STATUS
"Google Mock was not found - tests based on that will not build") "Google Mock was not found - tests based on that will not build")
endif()
endif() endif()

View File

@ -1,4 +1,5 @@
if (TARGET gmock) if(BUILD_TESTING)
if(TARGET gmock)
message(STATUS "Google Mock found - building tests") message(STATUS "Google Mock found - building tests")
set(TEST_SOURCES set(TEST_SOURCES
@ -52,4 +53,5 @@ if (TARGET gmock)
add_test(NAME glslang-gtests add_test(NAME glslang-gtests
COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}") COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}")
endif()
endif() endif()