[CMake] Makefile to CMakeLists.txt (GTEST)

Kevyn-Alexandre Paré kapare at rogue-research.com
Mon Nov 29 17:55:15 EST 2010


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é



More information about the CMake mailing list