Skip to content

Commit

Permalink
Merge branch 'gtest' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Feb 9, 2018
2 parents 7d63160 + 643bd8e commit 7eae586
Show file tree
Hide file tree
Showing 179 changed files with 122 additions and 126,539 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ before_install:
- '[[ "$TRAVIS_EVENT_TYPE" = cron ]] && export YARP_CHECKOUT=devel || export YARP_CHECKOUT=master'

install:
#-- Install cmake
- sudo apt-get install cmake
#-- Install googletest
- sudo apt-get install libgtest-dev
#-- Install yarp
- git clone --branch="$YARP_CHECKOUT" https://github.com/robotology/yarp
- cd yarp && mkdir build && cd build
Expand Down
95 changes: 95 additions & 0 deletions cmake/FindGTestSources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# 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(_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)")
set(GTestSources_VERSION GTestSources_VERSION-NOT_FOUND)
endif()

set(CMAKE_REQUIRED_INCLUDES "${_cmake_include_dirs}")

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

mark_as_advanced(GTestSources_SOURCE_DIR
GTestSources_INCLUDE_DIR)
7 changes: 6 additions & 1 deletion doc/tools-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ First install the dependencies:
- [Install CMake](https://github.com/roboticslab-uc3m/installation-guides/blob/master/install-cmake.md)
- [Install YARP](https://github.com/roboticslab-uc3m/installation-guides/blob/master/install-yarp.md)

Additionally, this project depends on YCM to download and build external packages. Although this process is intended to run automatically during the CMake configuration phase, you may still want to install YCM and said packages by yourself. In that respect, refer to [Install YCM](https://github.com/roboticslab-uc3m/installation-guides/blob/master/install-ycm.md) and to the installation guides of any package listed below:

- [color-debug](https://github.com/roboticslab-uc3m/color-debug)

For unit testing, you'll need the googletest source package. Refer to [Install googletest](https://github.com/roboticslab-uc3m/installation-guides/blob/master/install-googletest.md).

### Install tools on Ubuntu (working on all tested versions)

Our software integrates the previous dependencies. Note that you will be prompted for your password upon using `sudo` a couple of times:
Expand All @@ -25,4 +31,3 @@ export ROBOTICSLAB_TOOLS_DIR=$HOME/repos/tools/build # Points to where TEOConfi
```

For additional options use `ccmake` instead of `cmake`.

20 changes: 17 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Testing things #########################################################################################

add_subdirectory(gtest-1.7.0)
find_package(GTestSources 1.6.0 QUIET)

add_subdirectory(testPlayback)
add_subdirectory(testPlaybackThread)
if(NOT GTestSources_FOUND AND (NOT DEFINED ENABLE_tests OR ENABLE_tests))
message(WARNING "GTestSources package not found, disabling tests")
endif()

cmake_dependent_option(ENABLE_tests "Enable/disable unit tests" ON
GTestSources_FOUND OFF)

if(ENABLE_tests)
add_subdirectory(${GTestSources_SOURCE_DIR} ${CMAKE_BINARY_DIR}/gtest)

include_directories(${GTestSources_INCLUDE_DIR})

add_subdirectory(testPlayback)
add_subdirectory(testPlaybackThread)
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.

0 comments on commit 7eae586

Please sign in to comment.