Skip to content

Commit

Permalink
Remove local copy of googletest framework
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Mar 16, 2018
1 parent 5d81fbc commit c414653
Show file tree
Hide file tree
Showing 177 changed files with 125 additions and 126,537 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install libsoqt4-dev libcoin80-dev; fi
#-- Install Aquila deps
- sudo apt-get install libsfml-dev
#-- Install googletest
- sudo apt-get install libgtest-dev

install:
#-- Install opencv
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ set(XGNITIVE_LIBRARIES CACHE INTERNAL "appended libraries" FORCE)
add_subdirectory(share)
add_subdirectory(libraries)
add_subdirectory(programs)
if (ENABLE_tests)
add_subdirectory(tests)
endif (ENABLE_tests)
add_subdirectory(tests)

# export our variables to a XGNITIVEConfig.cmake creation
set(XGNITIVE_LINK_DIRS ${XGNITIVE_LINK_DIRS} ${LIBRARY_OUTPUT_PATH})
Expand Down
100 changes: 100 additions & 0 deletions cmake/FindGTestSources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Find the GTest headers and sources.
#
# Sets the following variables:
#
# * GTestSources_FOUND - system has GTest sources
# * GTestSources_SOURCE_DIR - GTest source dir (with CMakeLists.txt)
# * GTestSources_INCLUDE_DIR - GTest include directory (public headers)
# * GTestSources_VERSION - GTest version (if supported)
#
# You can set the GTEST_ROOT environment variable to be used as a
# hint by FindGTestSources to locate googletest source directory.
#
# Tested with the Ubuntu package `libgtest-dev` and the googletest
# repository hosted on GitHub and cloned to the local machine.
#
# Supported versions: v1.6, v1.7, v1.8.
#
# Also, this module adds the following macros:
#
# * gtest_add_tests (as in FindGTest.cmake)

find_package(GTest QUIET)

if(NOT GTestSources_SOURCE_DIR)
find_path(GTestSources_SOURCE_DIR src/gtest.cc
HINTS $ENV{GTEST_ROOT}
${GTEST_ROOT}
PATHS /usr/src/gtest
/usr/src/googletest
PATH_SUFFIXES googletest)
endif()

if(NOT GTestSources_INCLUDE_DIR)
# Look for local headers *before* /usr/include (hence the NO_X_PATH params)
find_path(GTestSources_INCLUDE_DIR gtest/gtest.h
HINTS ${GTestSources_SOURCE_DIR}
$ENV{GTEST_ROOT}
${GTEST_ROOT}
PATH_SUFFIXES include
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH)
endif()

set(GTestSources_VERSION GTestSources_VERSION-NOT_FOUND)

if(GTestSources_SOURCE_DIR AND GTestSources_INCLUDE_DIR)
set(_cmake_include_dirs ${CMAKE_REQUIRED_INCLUDES})

include(CheckCXXSourceCompiles)
list(APPEND CMAKE_REQUIRED_INCLUDES ${GTestSources_INCLUDE_DIR})

check_cxx_source_compiles("
#include <gtest/gtest.h>
int main() {
typedef const char* (testing::TestInfo::*fun)() const;
fun f = &testing::TestInfo::type_param;
return 0;
}"
_gtest_compatible_1_6_0)

check_cxx_source_compiles("
#include <gtest/gtest.h>
int main() {
typedef bool (testing::TestInfo::*fun)() const;
fun f = &testing::TestInfo::is_reportable;
return 0;
}"
_gtest_compatible_1_7_0)

check_cxx_source_compiles("
#include <gtest/gtest.h>
int main() {
typedef const char* (testing::TestInfo::*fun)() const;
fun f = &testing::TestInfo::file;
return 0;
}"
_gtest_compatible_1_8_0)

if(_gtest_compatible_1_8_0)
set(GTestSources_VERSION 1.8.0)
elseif(_gtest_compatible_1_7_0)
set(GTestSources_VERSION 1.7.0)
elseif(_gtest_compatible_1_6_0)
set(GTestSources_VERSION 1.6.0)
else()
message(STATUS "FindGTestSources.cmake reports unhandled GTest version (<1.6.0)")
endif()

set(CMAKE_REQUIRED_INCLUDES "${_cmake_include_dirs}")
unset(_cmake_include_dirs)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GTestSources FOUND_VAR GTestSources_FOUND
REQUIRED_VARS GTestSources_SOURCE_DIR
GTestSources_INCLUDE_DIR
VERSION_VAR GTestSources_VERSION)

mark_as_advanced(GTestSources_SOURCE_DIR
GTestSources_INCLUDE_DIR)
31 changes: 22 additions & 9 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Testing things #########################################################################################
add_subdirectory(gtest-1.7.0)
enable_testing()
find_package(GTestSources 1.6.0 QUIET)

find_package(YARP REQUIRED)
if(NOT GTestSources_FOUND AND (NOT DEFINED ENABLE_tests OR ENABLE_tests))
message(WARNING "GTestSources package not found, disabling tests")
endif()

add_definitions(${XGNITIVE_DEFINITIONS})
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ${YARP_INCLUDE_DIRS} ${XGNITIVE_INCLUDE_DIRS})
link_directories(${XGNITIVE_LINK_DIRS})
include(CMakeDependentOption)
cmake_dependent_option(ENABLE_tests "Enable/disable unit tests" ON
GTestSources_FOUND OFF)

add_executable(testCgdaRecognitionLib testCgdaRecognitionLib.cpp)
target_link_libraries(testCgdaRecognitionLib ${YARP_LIBRARIES} ${XGNITIVE_LIBRARIES} gtest gtest_main)
if(ENABLE_tests)

find_package(YARP REQUIRED)

add_definitions(${XGNITIVE_DEFINITIONS})
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ${YARP_INCLUDE_DIRS} ${XGNITIVE_INCLUDE_DIRS})
link_directories(${XGNITIVE_LINK_DIRS})

add_executable(testCgdaRecognitionLib testCgdaRecognitionLib.cpp)
target_link_libraries(testCgdaRecognitionLib ${YARP_LIBRARIES} ${XGNITIVE_LIBRARIES} gtest gtest_main)

else()

set(ENABLE_tests OFF CACHE BOOL "Enable/disable unit tests" FORCE)

endif()
157 changes: 0 additions & 157 deletions tests/gtest-1.7.0/CHANGES

This file was deleted.

Loading

0 comments on commit c414653

Please sign in to comment.