From 8a7bf1e2b6499cccaf92bd36ce30f10643b7719a Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Tue, 29 Jan 2019 19:15:51 +0100 Subject: [PATCH] Use GMock config from cmake-extras --- CMakeLists.txt | 2 +- cmake/FindGtest.cmake | 64 ------------------------------------------- 2 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 cmake/FindGtest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 87e95fa..5b7e4d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ enable_testing() option(MIR_ENABLE_TESTS "Build tests" ON) if (MIR_ENABLE_TESTS) - find_package(Gtest REQUIRED) + find_package(GMock REQUIRED) include_directories(${MIRCLIENT_INCLUDE_DIRS} ) include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) add_subdirectory(tests/) diff --git a/cmake/FindGtest.cmake b/cmake/FindGtest.cmake deleted file mode 100644 index 15a34a1..0000000 --- a/cmake/FindGtest.cmake +++ /dev/null @@ -1,64 +0,0 @@ -include(ExternalProject) -include(FindPackageHandleStandardArgs) - -#gtest -if(EXISTS /usr/src/googletest) - set(USING_GOOGLETEST_1_8 TRUE) - set(GTEST_INSTALL_DIR /usr/src/googletest/googletest/include) -else() - set(GTEST_INSTALL_DIR /usr/src/gmock/gtest/include) -endif() - -find_path(GTEST_INCLUDE_DIR gtest/gtest.h - HINTS ${GTEST_INSTALL_DIR}) - -#gmock -find_path(GMOCK_INSTALL_DIR CMakeLists.txt - HINTS /usr/src/googletest /usr/src/gmock) -if(${GMOCK_INSTALL_DIR} STREQUAL "GMOCK_INSTALL_DIR-NOTFOUND") - message(FATAL_ERROR "google-mock package not found") -endif() - -find_path(GMOCK_INCLUDE_DIR gmock/gmock.h) - -if (USING_GOOGLETEST_1_8) - set(GMOCK_BASE_BINARY_DIR ${CMAKE_BINARY_DIR}/gmock/libs) - set(GMOCK_BINARY_DIR ${GMOCK_BASE_BINARY_DIR}/googlemock) - set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest) -else() - set(GMOCK_BASE_BINARY_DIR ${CMAKE_BINARY_DIR}/gmock/libs) - set(GMOCK_BINARY_DIR ${GMOCK_BASE_BINARY_DIR}) - set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest) -endif() - -set(GTEST_CMAKE_ARGS "") - -if (USING_GOOGLETEST_1_8) - list(APPEND GTEST_CMAKE_ARGS -DBUILD_GTEST=ON) -endif() - -ExternalProject_Add( - GMock - #where to build in source tree - PREFIX ${GMOCK_PREFIX} - #where the source is external to the project - SOURCE_DIR ${GMOCK_INSTALL_DIR} - #forward the compilers to the subproject so cross-arch builds work - CMAKE_ARGS ${GTEST_CMAKE_ARGS} - BINARY_DIR ${GMOCK_BASE_BINARY_DIR} - - #we don't need to install, so skip - INSTALL_COMMAND "" -) - -set(GMOCK_LIBRARY ${GMOCK_BINARY_DIR}/libgmock.a) -set(GMOCK_MAIN_LIBRARY ${GMOCK_BINARY_DIR}/libgmock_main.a) -set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY}) -set(GTEST_LIBRARY ${GTEST_BINARY_DIR}/libgtest.a) -set(GTEST_MAIN_LIBRARY ${GTEST_BINARY_DIR}/libgtest_main.a) -set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY}) -set(GTEST_ALL_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES}) - -find_package_handle_standard_args(GTest DEFAULT_MSG - GMOCK_INCLUDE_DIR - GTEST_INCLUDE_DIR) -- 2.20.1