Skip to content

Commit

Permalink
disable googletests for cmake < 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
klirichek committed Nov 12, 2017
1 parent d043f7e commit f2133cc
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -163,30 +163,31 @@ endif ( SPLIT_SYMBOLS )


if ( NOT DISABLE_TESTING ) if ( NOT DISABLE_TESTING )
# Read docs at https://github.com/google/googletest.git # Read docs at https://github.com/google/googletest.git
include ( GetGoogletest ) if ( CMAKE_VERSION VERSION_LESS 3.1.0 )
if ( HAVE_GOOGLETEST ) message ( STATUS "Google tests disabled for old cmake (<3.1.0)")
set ( GTESTS_SRC ${SEARCHD_SRCS_TESTABLE} gtests_rtstuff.cpp gtests_tokenizer.cpp gtests_text.cpp else()
gtests_functions.cpp gtests_globalstate.cpp gtests_searchd.cpp) include ( GetGoogletest )
add_executable ( gmanticoretest ${GTESTS_SRC} ) if ( HAVE_GOOGLETEST )
target_link_libraries ( gmanticoretest gmock_main libsphinx ${EXTRA_LIBRARIES} ) set ( GTESTS_SRC ${SEARCHD_SRCS_TESTABLE} gtests_rtstuff.cpp gtests_tokenizer.cpp gtests_text.cpp
if ( CMAKE_VERSION VERSION_LESS 3.1.0 ) gtests_functions.cpp gtests_globalstate.cpp gtests_searchd.cpp)
add_test ( NAME googletests COMMAND gmanticoretest ) add_executable ( gmanticoretest ${GTESTS_SRC} )
message ( STATUS "Common google-tests added instead of individual due to old cmake (need >=3.1.0, have ${CMAKE_VERSION})" ) target_link_libraries ( gmanticoretest gmock_main libsphinx ${EXTRA_LIBRARIES} )
elseif ( CMAKE_VERSION VERSION_LESS 3.9.0 )# freshest cmake able to discover google-tests if ( CMAKE_VERSION VERSION_LESS 3.9.0 )# freshest cmake able to discover google-tests
find_package ( GTest QUIET ) find_package ( GTest QUIET )
GTEST_ADD_TESTS ( gmanticoretest "" ${GTESTS_SRC} ) GTEST_ADD_TESTS ( gmanticoretest "" ${GTESTS_SRC} )
message ( STATUS "Added individual google-tests" ) message ( STATUS "Added individual google-tests" )
elseif ( CMAKE_VERSION VERSION_LESS 3.10.0 ) elseif ( CMAKE_VERSION VERSION_LESS 3.10.0 )
include ( GoogleTest ) include ( GoogleTest )
GTEST_ADD_TESTS ( TARGET gmanticoretest SOURCES "${GTESTS_SRC}" TEST_LIST gTests ) GTEST_ADD_TESTS ( TARGET gmanticoretest SOURCES "${GTESTS_SRC}" TEST_LIST gTests )
SET_TESTS_PROPERTIES ( ${gTests} PROPERTIES LABELS GOOGLE ) SET_TESTS_PROPERTIES ( ${gTests} PROPERTIES LABELS GOOGLE )
message ( STATUS "Added individual google-tests" ) message ( STATUS "Added individual google-tests" )
else() # freshest cmake able to discover google-tests else() # freshest cmake able to discover google-tests
include ( GoogleTest ) include ( GoogleTest )
GTEST_DISCOVER_TESTS ( gmanticoretest PROPERTIES LABELS GOOGLE ) GTEST_DISCOVER_TESTS ( gmanticoretest PROPERTIES LABELS GOOGLE )
message ( STATUS "Discovered and added individual google-tests" ) message ( STATUS "Discovered and added individual google-tests" )
endif () endif ()
endif ( HAVE_GOOGLETEST ) endif ( HAVE_GOOGLETEST )
endif ( CMAKE_VERSION VERSION_LESS 3.1.0 )


add_executable ( tests ${TESTS_SRCS} ) add_executable ( tests ${TESTS_SRCS} )
target_link_libraries ( tests libsphinx ${EXTRA_LIBRARIES} ) target_link_libraries ( tests libsphinx ${EXTRA_LIBRARIES} )
Expand Down

0 comments on commit f2133cc

Please sign in to comment.