Permalink
Browse files

disable googletests for cmake < 3.1.0

  • Loading branch information...
klirichek committed Nov 12, 2017
1 parent d043f7e commit f2133ccb57e54370caf9e094e697e5aade010f24
Showing with 25 additions and 24 deletions.
  1. +25 −24 src/CMakeLists.txt
@@ -163,30 +163,31 @@ endif ( SPLIT_SYMBOLS )
if ( NOT DISABLE_TESTING )
# Read docs at https://github.com/google/googletest.git
include ( GetGoogletest )
if ( HAVE_GOOGLETEST )
set ( GTESTS_SRC ${SEARCHD_SRCS_TESTABLE} gtests_rtstuff.cpp gtests_tokenizer.cpp gtests_text.cpp
gtests_functions.cpp gtests_globalstate.cpp gtests_searchd.cpp)
add_executable ( gmanticoretest ${GTESTS_SRC} )
target_link_libraries ( gmanticoretest gmock_main libsphinx ${EXTRA_LIBRARIES} )
if ( CMAKE_VERSION VERSION_LESS 3.1.0 )
add_test ( NAME googletests COMMAND gmanticoretest )
message ( STATUS "Common google-tests added instead of individual due to old cmake (need >=3.1.0, have ${CMAKE_VERSION})" )
elseif ( CMAKE_VERSION VERSION_LESS 3.9.0 )# freshest cmake able to discover google-tests
find_package ( GTest QUIET )
GTEST_ADD_TESTS ( gmanticoretest "" ${GTESTS_SRC} )
message ( STATUS "Added individual google-tests" )
elseif ( CMAKE_VERSION VERSION_LESS 3.10.0 )
include ( GoogleTest )
GTEST_ADD_TESTS ( TARGET gmanticoretest SOURCES "${GTESTS_SRC}" TEST_LIST gTests )
SET_TESTS_PROPERTIES ( ${gTests} PROPERTIES LABELS GOOGLE )
message ( STATUS "Added individual google-tests" )
else() # freshest cmake able to discover google-tests
include ( GoogleTest )
GTEST_DISCOVER_TESTS ( gmanticoretest PROPERTIES LABELS GOOGLE )
message ( STATUS "Discovered and added individual google-tests" )
endif ()
endif ( HAVE_GOOGLETEST )
if ( CMAKE_VERSION VERSION_LESS 3.1.0 )
message ( STATUS "Google tests disabled for old cmake (<3.1.0)")
else()
include ( GetGoogletest )
if ( HAVE_GOOGLETEST )
set ( GTESTS_SRC ${SEARCHD_SRCS_TESTABLE} gtests_rtstuff.cpp gtests_tokenizer.cpp gtests_text.cpp
gtests_functions.cpp gtests_globalstate.cpp gtests_searchd.cpp)
add_executable ( gmanticoretest ${GTESTS_SRC} )
target_link_libraries ( gmanticoretest gmock_main libsphinx ${EXTRA_LIBRARIES} )
if ( CMAKE_VERSION VERSION_LESS 3.9.0 )# freshest cmake able to discover google-tests
find_package ( GTest QUIET )
GTEST_ADD_TESTS ( gmanticoretest "" ${GTESTS_SRC} )
message ( STATUS "Added individual google-tests" )
elseif ( CMAKE_VERSION VERSION_LESS 3.10.0 )
include ( GoogleTest )
GTEST_ADD_TESTS ( TARGET gmanticoretest SOURCES "${GTESTS_SRC}" TEST_LIST gTests )
SET_TESTS_PROPERTIES ( ${gTests} PROPERTIES LABELS GOOGLE )
message ( STATUS "Added individual google-tests" )
else() # freshest cmake able to discover google-tests
include ( GoogleTest )
GTEST_DISCOVER_TESTS ( gmanticoretest PROPERTIES LABELS GOOGLE )
message ( STATUS "Discovered and added individual google-tests" )
endif ()
endif ( HAVE_GOOGLETEST )
endif ( CMAKE_VERSION VERSION_LESS 3.1.0 )
add_executable ( tests ${TESTS_SRCS} )
target_link_libraries ( tests libsphinx ${EXTRA_LIBRARIES} )

0 comments on commit f2133cc

Please sign in to comment.