Re: [CMake] Makefile to CMakeLists.txt (GTEST)
Yes it's true I didn't think of this one. It work nicely, here what I have done: wget http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 tar xjvf gtest-1.5.0.tar.bz2 cd gtest-1.5.0 mkdir my-test vim CMakeLists.txt # Add ADD_SUBDIRECTORY(my-test) cd my-test # SIMPLE HEADER FILE vim source.h void function (); # SIMPLE SOURCE vim source.c #include stdio.h void function () { printf(my function to test\n); } # SIMPLE TEST vim ut_source.cc #include limits.h #include unistd.h #include gtest/gtest.h #include source.h static int something() { function(); return 0; } TEST(RRThread, CreateThread) { EXPECT_EQ(0, something()); } vim CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(UnitTests) INCLUDE_DIRECTORIES(~/gtest-1.5.0/my-test) ADD_EXECUTABLE(UT ut_source.cc source.c) TARGET_LINK_LIBRARIES(UT pthread ~/gtest-1.5.0/my-build/libgtest.a ~/gtest-1.5.0/my-build/libgtest_main.a) cd .. mkdir my-build cd my-build ccmake .. make Best Regards, Kevyn-Alexandre Paré On Wed, 2010-12-01 at 10:43 -0800, Ben Medina wrote: Note that recent versions of gtest come with a CMakeLists.txt, so you can just use add_subdirectory on the gtest source tree. - Ben On Wed, Dec 1, 2010 at 7:59 AM, Kevyn-Alexandre Paré kap...@rogue-research.com wrote: Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? Regards -- Kevyn-Alexandre Paré On Mon, 2010-11-29 at 18:17 -0500, Philip Lowman wrote: 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é kap...@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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
Thx for replying, But it didn't change by switching it. Regards, Kevyn-Alexandre Paré On Wed, 2010-12-01 at 22:14 +, Fraser Hutchison wrote: Hi Kevyn-Alexandre, I think moving the -lpthread to after ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a should help. Cheers, Fraser. On 01/12/2010 3:59 PM, Kevyn-Alexandre Paré wrote: Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? Regards -- Kevyn-Alexandre Paré On Mon, 2010-11-29 at 18:17 -0500, Philip Lowman wrote: 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é kap...@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 ___ 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 ___ 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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
Thx for replying, It seem that my simple example and using a add_subdirectory and reusing CMakelists.txt of the gtest source solved my problem. Regards, On Sat, 2010-12-04 at 05:48 -0500, Philip Lowman wrote: On Wed, Dec 1, 2010 at 10:59 AM, Kevyn-Alexandre Paré kap...@rogue-research.com wrote: Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I'm not sure what exactly has gone wrong here. You might want to try to find the exitThread symbol to see where it lives using nm or strings on the libraries that you have. If all else fails, perhaps check on a GTest forum? I've never had this problem before but I don't recall ever using the gtest static libraries either. I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? I don't see anything wrong with what you have in terms of the GCC invocation. You'll need to explicitly specify the libraries during compile time to resolve those symbols and produce a binary as far as I know. I'm not sure why you're using add_custom_target() when you could just use add_executable() and target_link_libraries(), but I doubt this has anything to do with your undefined symbol reference. -- Philip Lowman ___ 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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
Just want to say that since I want to test C code i need this in my header file (for more details see http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B% 2B#Linking_C_and_C.2B.2B_code): #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */ extern C { #endif void function (); #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */ } #endif On Tue, 2010-12-07 at 12:10 -0500, Kevyn-Alexandre Paré wrote: Yes it's true I didn't think of this one. It work nicely, here what I have done: wget http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 tar xjvf gtest-1.5.0.tar.bz2 cd gtest-1.5.0 mkdir my-test vim CMakeLists.txt # Add ADD_SUBDIRECTORY(my-test) cd my-test # SIMPLE HEADER FILE vim source.h void function (); # SIMPLE SOURCE vim source.c #include stdio.h void function () { printf(my function to test\n); } # SIMPLE TEST vim ut_source.cc #include limits.h #include unistd.h #include gtest/gtest.h #include source.h static int something() { function(); return 0; } TEST(RRThread, CreateThread) { EXPECT_EQ(0, something()); } vim CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(UnitTests) INCLUDE_DIRECTORIES(~/gtest-1.5.0/my-test) ADD_EXECUTABLE(UT ut_source.cc source.c) TARGET_LINK_LIBRARIES(UT pthread ~/gtest-1.5.0/my-build/libgtest.a ~/gtest-1.5.0/my-build/libgtest_main.a) cd .. mkdir my-build cd my-build ccmake .. make Best Regards, Kevyn-Alexandre Paré On Wed, 2010-12-01 at 10:43 -0800, Ben Medina wrote: Note that recent versions of gtest come with a CMakeLists.txt, so you can just use add_subdirectory on the gtest source tree. - Ben On Wed, Dec 1, 2010 at 7:59 AM, Kevyn-Alexandre Paré kap...@rogue-research.com wrote: Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? Regards -- Kevyn-Alexandre Paré On Mon, 2010-11-29 at 18:17 -0500, Philip Lowman wrote: 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é kap...@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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
On Wed, Dec 1, 2010 at 10:59 AM, Kevyn-Alexandre Paré kap...@rogue-research.com wrote: Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I'm not sure what exactly has gone wrong here. You might want to try to find the exitThread symbol to see where it lives using nm or strings on the libraries that you have. If all else fails, perhaps check on a GTest forum? I've never had this problem before but I don't recall ever using the gtest static libraries either. I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? I don't see anything wrong with what you have in terms of the GCC invocation. You'll need to explicitly specify the libraries during compile time to resolve those symbols and produce a binary as far as I know. I'm not sure why you're using add_custom_target() when you could just use add_executable() and target_link_libraries(), but I doubt this has anything to do with your undefined symbol reference. -- Philip Lowman ___ 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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? Regards -- Kevyn-Alexandre Paré On Mon, 2010-11-29 at 18:17 -0500, Philip Lowman wrote: 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é kap...@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 ___ 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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
Note that recent versions of gtest come with a CMakeLists.txt, so you can just use add_subdirectory on the gtest source tree. - Ben On Wed, Dec 1, 2010 at 7:59 AM, Kevyn-Alexandre Paré kap...@rogue-research.com wrote: Philip, Thx for the reply. Neither of these solutions change a thing. I try to play with ADD_CUSTOM_TARGET but same error... ADD_CUSTOM_TARGET(RRThread.o ALL COMMAND ${CMAKE_C_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread -c ${MICRONTRACKER_COMMON_PATH}RRThread.c ${UNIT_TEST_PATH}common/UT_RRThread.cc) ADD_CUSTOM_TARGET(UT_RRThread ALL COMMAND ${CMAKE_CXX_COMPILER} -I ${MICRONTRACKER_COMMON_PATH} -I${GTEST_HEADER_PATH} -lpthread RRThread.o UT_RRThread.o ${GTEST_LIB_PATH}gtest.a ${GTEST_LIB_PATH}gtest_main.a -o UT_RRThread) Result: UT_RRThread.o: In function `thread_proc(void*)': UT_RRThread.cc:(.text+0x28): undefined reference to `exitThread()' ... I pretty sure that I'm missing little detail. How can I implicitly add dependency to the object during the linking? Regards -- Kevyn-Alexandre Paré On Mon, 2010-11-29 at 18:17 -0500, Philip Lowman wrote: 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é kap...@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 ___ 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 ___ 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
[CMake] Makefile to CMakeLists.txt (GTEST)
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
Re: [CMake] Makefile to CMakeLists.txt (GTEST)
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é kap...@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 ___ 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