Try adding the "gtest.a" library as well. Also, order does matter when you are linking static libraries so you might need to play with the ordering.<div><div><br></div><div>Also, when you get some time, have a look at FindGTest.cmake. It may help you simplify adding your tests.</div>
<div><div><div><br><div class="gmail_quote">On Mon, Nov 29, 2010 at 5:55 PM, Kevyn-Alexandre Paré <span dir="ltr"><<a href="mailto:kapare@rogue-research.com">kapare@rogue-research.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
/// -> What I trying to do is to compile my unit test with google test<br>
with cmake from a working Makefile.<br>
<br>
/// -> Here the Makefile::::<br>
<br>
RRThread.o : $(USER_DIR)/RRThread.c $(USER_DIR)/RRThread.h<br>
$(GTEST_HEADERS)<br>
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/RRThread.c<br>
<br>
UT_RRThread.o : $(UNITTEST_DIR)/UT_RRThread.cc \<br>
$(USER_DIR)/RRThread.h $(GTEST_HEADERS)#<br>
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(USER_DIR) -c<br>
$(UNITTEST_DIR)/UT_RRThread.cc<br>
<br>
UT_RRThread : RRThread.o UT_RRThread.o gtest_main.a<br>
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@<br>
<br>
<br>
/// -> Here how I thought of doing it with CMakeLists.txt:::<br>
<br>
INCLUDE_DIRECTORIES(${GTEST_HEADER} ${USER_DIR})<br>
<br>
ADD_EXECUTABLE(UT ${USER_DIR}RRThread.c ${UNIT_TEST_PATH}UT_RRThread.cc)<br>
<br>
TARGET_LINK_LIBRARIES(UT pthread ${GTEST_LIB_PATH}gtest_main.a)<br>
<br>
/// -> My result:<br>
<br>
Linking CXX executable UT<br>
/usr/bin/cmake -E cmake_link_script CMakeFiles/UT.dir/link.txt<br>
--verbose=1<br>
/usr/bin/c++ CMakeFiles/UT.dir/common/RRThread.c.o<br>
CMakeFiles/UT.dir/UnitTests/common/UT_RRThread.cc.o -o UT -rdynamic<br>
-lpthread /home/andromeda/rogue-research/3rdParty/gtest/trunk/Release/lib/gtest_main.a<br>
CMakeFiles/UT.dir/UnitTests/common/UT_RRThread.cc.o: In function<br>
`thread_proc(void*)':<br>
UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()'<br>
<br>
<br>
/// -> My question and my problem is:<br>
Since I'm including the USER_DIR with INCLUDE_DIRECTORIES why is it<br>
complaining about not finding reference that is in that header file?<br>
<br>
<br>
Best Regards,<br>
<br>
--<br>
Kevyn-Alexandre Paré<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a></blockquote></div><br><br clear="all"><br>-- <br>Philip Lowman<br>
</div></div></div></div>