Skip to content

Commit

Permalink
Use gtest installed from package managers (#139)
Browse files Browse the repository at this point in the history
* Use gtest installed from package managers

* Document gtest dependency

* Fix gtest_main target name in CMake
  • Loading branch information
traversaro authored Apr 3, 2024
1 parent fe4bbe6 commit 455486d
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ jobs:
sudo apt-get update
# YARP dependencies
sudo apt-get install git build-essential cmake ninja-build libace-dev libeigen3-dev libopencv-dev libtinyxml-dev
# gz-sim-yarp-plugins dependencies
sudo apt-get install gz-${{ matrix.gazebo_distro }}
# Test dependencies
sudo apt-get install libgtest-dev
- name: Cache Source-based Dependencies
id: cache-source-deps
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ installing the dependencies with conda-forge on Linux, macOS or Windows, or apt
Create and activate an environment with the required dependencies:

~~~
mamba create -c conda-forge -n gsypdev libgz-sim8 yarp ycm-cmake-modules cmake ninja pkg-config cmake compilers
mamba create -c conda-forge -n gsypdev libgz-sim8 yarp ycm-cmake-modules cmake ninja pkg-config cmake compilers gtest
mamba activate gsypdev
~~~

Expand Down Expand Up @@ -48,7 +48,7 @@ First install some necessary dependencies from apt

~~~
sudo apt-get update
sudo apt-get install lsb-release wget gnupg cmake pkg-config ninja-build build-essential
sudo apt-get install lsb-release wget gnupg cmake pkg-config ninja-build build-essential libgtest-dev
~~~

Then install Gazebo Harmonic:
Expand Down
1 change: 1 addition & 0 deletions ci_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dependencies:
- pkg-config
- libgz-sim8
- yarp
- gtest
9 changes: 1 addition & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Fetch and configure GTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
find_package(GTest REQUIRED)

add_subdirectory(forcetorque)
add_subdirectory(imu)
Expand Down
2 changes: 1 addition & 1 deletion tests/camera/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_executable(CameraTest CameraTest.cc)
target_link_libraries(CameraTest
gtest_main
GTest::gtest_main
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
${YARP_LIBRARIES}
Expand Down
2 changes: 1 addition & 1 deletion tests/clock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_executable(ClockTest ClockTest.cc)
target_link_libraries(ClockTest
gtest_main
GTest::gtest_main
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
YARP::YARP_dev
Expand Down
2 changes: 1 addition & 1 deletion tests/commons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_executable(ConfigurationParsingTest ConfigurationParsingTest.cc)

target_link_libraries(ConfigurationParsingTest
PRIVATE
gtest_main
GTest::gtest_main
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
YARP::YARP_dev
Expand Down
2 changes: 1 addition & 1 deletion tests/controlboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ foreach(TEST ${TESTS})
add_executable(${TEST} ${TEST}.cc)

target_link_libraries(${TEST}
PRIVATE gtest_main
PRIVATE GTest::gtest_main
PRIVATE gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
PRIVATE gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion tests/forcetorque/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_executable(ForceTorqueTest ForceTorqueTest.cc)
target_link_libraries(ForceTorqueTest
gtest_main
GTest::gtest_main
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
${YARP_LIBRARIES}
Expand Down
2 changes: 1 addition & 1 deletion tests/imu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_executable(ImuTest ImuTest.cc)
target_link_libraries(ImuTest
PRIVATE gtest_main
PRIVATE GTest::gtest_main
PRIVATE gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
PRIVATE gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion tests/laser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_executable(LaserTest LaserTest.cc)
target_link_libraries(LaserTest
gtest_main
GTest::gtest_main
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
${YARP_LIBRARIES}
Expand Down

0 comments on commit 455486d

Please sign in to comment.