1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 12:28:31 +01:00

Use system gtest and gmock if available. Fixes issue 1653

This commit is contained in:
David Sansome 2011-03-29 19:05:13 +00:00
parent 96b9321d3b
commit e69502dfd3
2 changed files with 34 additions and 13 deletions

View File

@ -308,6 +308,18 @@ if(NOT ECHONEST_INCLUDE_DIRS OR NOT ECHONEST_LIBRARIES)
set(ECHONEST_LIBRARIES echonest)
endif(NOT ECHONEST_INCLUDE_DIRS OR NOT ECHONEST_LIBRARIES)
# Use system gmock if it's available
# We need to look for both gmock and gtest
find_path(GMOCK_INCLUDE_DIRS gmock/gmock.h)
find_library(GMOCK_LIBRARIES gmock)
if(GMOCK_INCLUDE_DIRS)
find_path(GTEST_INCLUDE_DIRS gtest/gtest.h)
find_library(GTEST_LIBRARIES gtest)
if(GTEST_INCLUDE_DIRS)
set(USE_SYSTEM_GMOCK 1)
set(GMOCK_LIBRARIES ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES})
endif(GTEST_INCLUDE_DIRS)
endif(GMOCK_INCLUDE_DIRS)
# Subdirectories
add_subdirectory(src)

View File

@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 2.6)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest)
if(USE_SYSTEM_GMOCK)
include_directories(${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
else(USE_SYSTEM_GMOCK)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest)
endif(USE_SYSTEM_GMOCK)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
include_directories(${QT_QTTEST_INCLUDE_DIR})
@ -15,28 +20,32 @@ if(HAVE_LIBLASTFM)
include_directories(${LASTFM_INCLUDE_DIRS})
endif(HAVE_LIBLASTFM)
set(GTEST-SOURCES
if(NOT USE_SYSTEM_GMOCK)
set(GTEST-SOURCES
../3rdparty/gmock/gtest/src/gtest.cc
../3rdparty/gmock/gtest/src/gtest-death-test.cc
../3rdparty/gmock/gtest/src/gtest-filepath.cc
../3rdparty/gmock/gtest/src/gtest-port.cc
../3rdparty/gmock/gtest/src/gtest-test-part.cc
../3rdparty/gmock/gtest/src/gtest-typed-test.cc
)
)
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
add_library(gtest STATIC EXCLUDE_FROM_ALL ${GTEST-SOURCES})
add_library(gtest STATIC EXCLUDE_FROM_ALL ${GTEST-SOURCES})
set(GMOCK-SOURCES
set(GMOCK-SOURCES
../3rdparty/gmock/src/gmock-cardinalities.cc
../3rdparty/gmock/src/gmock.cc
../3rdparty/gmock/src/gmock-internal-utils.cc
../3rdparty/gmock/src/gmock-matchers.cc
../3rdparty/gmock/src/gmock-printers.cc
../3rdparty/gmock/src/gmock-spec-builders.cc)
../3rdparty/gmock/src/gmock-spec-builders.cc
)
add_library(gmock STATIC EXCLUDE_FROM_ALL ${GMOCK-SOURCES})
target_link_libraries(gmock gtest)
add_library(gmock STATIC EXCLUDE_FROM_ALL ${GMOCK-SOURCES})
set(GMOCK_LIBRARIES gmock gtest)
endif(NOT USE_SYSTEM_GMOCK)
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
set(TESTUTILS-SOURCES
test_utils.cpp
@ -52,7 +61,7 @@ set(TESTUTILS-MOC-HEADERS
qt4_wrap_cpp(TESTUTILS-SOURCES-MOC ${TESTUTILS-MOC-HEADERS})
add_library(test_utils STATIC EXCLUDE_FROM_ALL ${TESTUTILS-SOURCES} ${TESTUTILS-SOURCES-MOC})
target_link_libraries(test_utils gmock ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
target_link_libraries(test_utils ${GMOCK_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
add_custom_target(test
echo "Running tests"
@ -79,7 +88,7 @@ macro(add_test_file test_source gui_required)
EXCLUDE_FROM_ALL
${test_source}
)
target_link_libraries(${TEST_NAME} gmock clementine_lib test_utils)
target_link_libraries(${TEST_NAME} ${GMOCK_LIBRARIES} clementine_lib test_utils)
set(GUI_REQUIRED ${gui_required})
if (GUI_REQUIRED)
target_link_libraries(${TEST_NAME} test_gui_main)