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 1c4ff46 + d5a4044 commit 93b37d4
Show file tree
Hide file tree
Showing 183 changed files with 133 additions and 141,133 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ before_install:
- '[[ "$TRAVIS_EVENT_TYPE" = cron ]] && export YARP_CHECKOUT=devel || export YARP_CHECKOUT=master'

install:
#-- Install eigen
- sudo apt-get install libeigen3-dev
#-- Install eigen and gtest
- sudo apt-get install libeigen3-dev 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)
63 changes: 36 additions & 27 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
option(ENABLE_tests "Choose if you want to compile tests" ON)
find_package(GTestSources 1.6.0 QUIET)

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(gtest-1.7.0)
enable_testing()
find_package(YARP REQUIRED)

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

get_property(_common_includes GLOBAL PROPERTY ROBOTICSLAB_KINEMATICS_DYNAMICS_INCLUDE_DIRS)

find_package(YARP REQUIRED)
include_directories(${GTestSources_INCLUDE_DIR}
${YARP_INCLUDE_DIRS}
${_common_includes})

get_property(_common_includes GLOBAL PROPERTY ROBOTICSLAB_KINEMATICS_DYNAMICS_INCLUDE_DIRS)
add_executable(testKinRepresentation testKinRepresentation.cpp)
add_dependencies(testKinRepresentation COLOR_DEBUG)
target_link_libraries(testKinRepresentation gtest_main KinematicRepresentationLib)

include_directories(${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR}
${YARP_INCLUDE_DIRS}
${_common_includes})
add_executable(testKdlSolver testKdlSolver.cpp)
add_dependencies(testKdlSolver COLOR_DEBUG)
target_link_libraries(testKdlSolver YARP::YARP_OS YARP::YARP_dev gtest_main)

add_executable(testKinRepresentation testKinRepresentation.cpp)
add_dependencies(testKinRepresentation COLOR_DEBUG)
target_link_libraries(testKinRepresentation gtest_main KinematicRepresentationLib)
add_executable(testKdlSolverFromFile testKdlSolverFromFile.cpp)
add_dependencies(testKdlSolverFromFile COLOR_DEBUG)
target_link_libraries(testKdlSolverFromFile YARP::YARP_OS YARP::YARP_dev gtest_main)

add_executable(testKdlSolver testKdlSolver.cpp)
add_dependencies(testKdlSolver COLOR_DEBUG)
target_link_libraries(testKdlSolver YARP::YARP_OS YARP::YARP_dev gtest_main)
add_executable(testAsibotSolverFromFile testAsibotSolverFromFile.cpp)
add_dependencies(testAsibotSolverFromFile COLOR_DEBUG)
target_link_libraries(testAsibotSolverFromFile YARP::YARP_OS YARP::YARP_dev gtest_main KinematicRepresentationLib)

add_executable(testKdlSolverFromFile testKdlSolverFromFile.cpp)
add_dependencies(testKdlSolverFromFile COLOR_DEBUG)
target_link_libraries(testKdlSolverFromFile YARP::YARP_OS YARP::YARP_dev gtest_main)
add_executable(testKdlTrajectory testKdlTrajectory.cpp)
add_dependencies(testKdlTrajectory COLOR_DEBUG)
target_link_libraries(testKdlTrajectory YARP::YARP_OS YARP::YARP_dev gtest_main TrajectoryLib)

add_executable(testAsibotSolverFromFile testAsibotSolverFromFile.cpp)
add_dependencies(testAsibotSolverFromFile COLOR_DEBUG)
target_link_libraries(testAsibotSolverFromFile YARP::YARP_OS YARP::YARP_dev gtest_main KinematicRepresentationLib)
add_executable(testBasicCartesianControl testBasicCartesianControl.cpp)
add_dependencies(testBasicCartesianControl COLOR_DEBUG)
target_link_libraries(testBasicCartesianControl YARP::YARP_OS YARP::YARP_dev gtest_main)

add_executable(testKdlTrajectory testKdlTrajectory.cpp)
add_dependencies(testKdlTrajectory COLOR_DEBUG)
target_link_libraries(testKdlTrajectory YARP::YARP_OS YARP::YARP_dev gtest_main TrajectoryLib)
else()

add_executable(testBasicCartesianControl testBasicCartesianControl.cpp)
add_dependencies(testBasicCartesianControl COLOR_DEBUG)
target_link_libraries(testBasicCartesianControl YARP::YARP_OS YARP::YARP_dev gtest_main)
set(ENABLE_tests OFF CACHE BOOL "Enable/disable unit tests" FORCE)

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

This file was deleted.

0 comments on commit 93b37d4

Please sign in to comment.