I am having trouble getting Cmake to work. I am using ROS and catkin_make. I have read the following: cmake undefined reference to function cmake undefined reference
but still cannot seem to get it compile. I am attempting to use Google unit testing on my code. I am new to cmake and google testing. I am sure I am missing something very small and obvious.
I have my tests in one file "test_usbl.cpp" and a main that should call all my tests.
This is my file:
usbl
├── CMakeLists.txt
├── CMakeLists.txt~
├── include
│ └── usbl
│ └── usblSim.h
├── package.xml
├── src
│ ├── usblSim.cpp
│ └── usblSim.cpp~
└── test
├── test_main.cpp
└── test_usbl.cpp
and this is my CMakeList.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
PROJECT(usbl)
SET(CMAKE_CXX_FLAGS "-g -std=c++0x ${CMAKE_CXX_FLAGS}")
FIND_PACKAGE(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
std_msgs
)
FIND_PACKAGE(GTest REQUIRED)
FIND_PACKAGE(Boost)
FIND_PACKAGE(Threads)
catkin_package( )
SET(INCLUDE_DIRS
${GTEST_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
include/usbl
)
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/usbl)
SET(SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/usblSim.cpp}
)
SET(LIBS
${ROS_LIBRARIES}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${GTEST_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
# simulator
#ADD_EXECUTABLE(usblSim src/usblSim.cpp)
add_library(usbl src/usblSim.cpp)
#TARGET_LINK_LIBRARIES(usblSim ${LIBS})
SET(USBL_TEST
test/test_usbl.cpp
test/test_main.cpp
)
ADD_EXECUTABLE(test_usbl ${USBL_TEST})
TARGET_LINK_LIBRARIES(test_usbl ${LIBS})
This is giving me the error:
CMakeFiles/test_usbl.dir/test/test_usbl.cpp.o: In function `meanTest_isEquel_Test::TestBody()':
/home/nathaniel/Documents/usbl/src/usbl/test/test_usbl.cpp:12: undefined reference to `usblSim::usblSim()'