add_rostest_gtest(...) not finding GTest libs
I have a rostest which cannot be built with catkin_make
.
In my CMakeLists.txt
I have normal gtest
catkin_add_gtest(test_coordinate
src/test/util/test_coordinate.cpp
src/test/degrees-radians.h
src/main/util/coordinate.h
src/main/util/coordinate.cpp)
target_link_libraries(test_coordinate ${catkin_LIBRARIES})
add_rostest_gtest(test_global_planner_integration src/test/global_planner_integration.test src/test/test_global_planner.cpp)
target_link_libraries(test_global_planner_integration ${catkin_LIBRARIES})
the normal gtest works fine and without the rostest lines it also builds without any errors. But when I add a rostest withadd_rostest_gtest()
I get the following build error
[ 48%] Built target my_project_generate_messages_nodejs
[ 58%] Built target my_project_generate_messages_lisp
[ 69%] Built target my_project_generate_messages_cpp
[ 84%] Built target my_project_generate_messages_py
[ 97%] Built target my_project_generate_messages_eus
[ 97%] Built target my_project_generate_messages
CMakeFiles/test_global_planner.dir/src/test/test_global_planner.cpp.o: In Funktion `TestSuite_testCase2_Test::TestBody()':
test_global_planner.cpp:(.text+0x4d0): undefined reference to `testing::Message::Message()'
test_global_planner.cpp:(.text+0x4f5): undefined reference to `testing::internal::GetBoolAssertionFailureMessage[abi:cxx11](testing::AssertionResult const&, char const*, char const*, char const*)'
test_global_planner.cpp:(.text+0x524): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
test_global_planner.cpp:(.text+0x537): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
test_global_planner.cpp:(.text+0x543): undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
test_global_planner.cpp:(.text+0x5d4): undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
CMakeFiles/test_global_planner.dir/src/test/test_global_planner.cpp.o: In Funktion `main':
test_global_planner.cpp:(.text+0x63f): undefined reference to `testing::InitGoogleTest(int*, char**)'
CMakeFiles/test_global_planner.dir/src/test/test_global_planner.cpp.o: In Funktion `__static_initialization_and_destruction_0(int, int)':
test_global_planner.cpp:(.text+0xdfb): undefined reference to `testing::internal::GetTestTypeId()'
test_global_planner.cpp:(.text+0xe75): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
this continues over several pages ... my test_global_planner.cpp
looks like this
#include <ros/init.h>
#include <gtest/gtest.h>
#include <armadillo>
TEST(TestSuite, testCase2) {
ROS_INFO("started test node");
ros::Duration(10.0).sleep();
EXPECT_TRUE(true);
}
// Run all the tests that were declared with TEST()
int main(int argc, char **argv) {
//ros::init(argc, argv, "test_global_planner_integration_node");
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
To me it looks like GTest cannot be found but this does not make sense
edit:
when I use add_library()
instead of add_executable()
the build finishes but the test cannot run because it not an executable anymore