[CMake] Makefile to CMakeLists.txt (GTEST)
Philip Lowman
philip at yhbt.com
Mon Nov 29 18:17:19 EST 2010
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.
Also, when you get some time, have a look at FindGTest.cmake. It may help
you simplify adding your tests.
On Mon, Nov 29, 2010 at 5:55 PM, Kevyn-Alexandre Paré <
kapare at rogue-research.com> wrote:
> Hi,
>
> /// -> What I trying to do is to compile my unit test with google test
> with cmake from a working Makefile.
>
> /// -> Here the Makefile::::
>
> RRThread.o : $(USER_DIR)/RRThread.c $(USER_DIR)/RRThread.h
> $(GTEST_HEADERS)
> $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/RRThread.c
>
> UT_RRThread.o : $(UNITTEST_DIR)/UT_RRThread.cc \
> $(USER_DIR)/RRThread.h $(GTEST_HEADERS)#
> $(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(USER_DIR) -c
> $(UNITTEST_DIR)/UT_RRThread.cc
>
> UT_RRThread : RRThread.o UT_RRThread.o gtest_main.a
> $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
>
>
> /// -> Here how I thought of doing it with CMakeLists.txt:::
>
> INCLUDE_DIRECTORIES(${GTEST_HEADER} ${USER_DIR})
>
> ADD_EXECUTABLE(UT ${USER_DIR}RRThread.c ${UNIT_TEST_PATH}UT_RRThread.cc)
>
> TARGET_LINK_LIBRARIES(UT pthread ${GTEST_LIB_PATH}gtest_main.a)
>
> /// -> My result:
>
> Linking CXX executable UT
> /usr/bin/cmake -E cmake_link_script CMakeFiles/UT.dir/link.txt
> --verbose=1
> /usr/bin/c++ CMakeFiles/UT.dir/common/RRThread.c.o
> CMakeFiles/UT.dir/UnitTests/common/UT_RRThread.cc.o -o UT -rdynamic
> -lpthread
> /home/andromeda/rogue-research/3rdParty/gtest/trunk/Release/lib/gtest_main.a
> CMakeFiles/UT.dir/UnitTests/common/UT_RRThread.cc.o: In function
> `thread_proc(void*)':
> UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()'
>
>
> /// -> My question and my problem is:
> Since I'm including the USER_DIR with INCLUDE_DIRECTORIES why is it
> complaining about not finding reference that is in that header file?
>
>
> Best Regards,
>
> --
> Kevyn-Alexandre Paré
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
--
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101129/03000b11/attachment-0001.htm>
More information about the CMake
mailing list