xuyongli73 / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Provide similar to gtest-config functionality for FindGTest.cmake module #279

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Some features of gtest-config missing in FindGTest.cmake module. Specifically 
`gtest-config 
--ldflags` and `gtest-config --libs` functionality required to link tests 
properly. After upgrading 
to gtest-1.5 from gtest-1.4 I had problems with missing -lpthread on linking 
stage. Maybe I 
can use
 execute_process (COMMAND gtest-config --libs OUTPUT_VARIABLE GTest_ld_flags   
OUTPUT_STRIP_TRAILING_WHITESPACE)
to solve this issue, but it seems that I'll lose portability.
Could you please add   GTest_CXX_FLAGS, GTest_LD_FLAGS, GTest_LIBS to 
FindGTest module?

Original issue reported on code.google.com by intergal...@gmail.com on 25 Apr 2010 at 9:16

GoogleCodeExporter commented 9 years ago
What system are you using Google Test on? What are the commands you use and 
what are the error messages?

Note that we do not write FindGTest.cmake; you should contact CMake authors 
about it.

Original comment by vladlosev on 27 Apr 2010 at 6:38

GoogleCodeExporter commented 9 years ago
> What system are you using Google Test on?
GNU/Linux, gtest-1.5.0, cmake-2.8.1

> What are the commands you use
add_executable (prgnm-test ${prgnm-test_srcs})
target_link_libraries (prgnm-test  gtest)
add_test(prgnm-test  prgnm-test)

> and what are the error messages?
Linking CXX executable prgnm-test
/usr/lib/gcc/i486-slackware-linux/4.4.3/../../../libgtest.so: undefined 
reference to `pthread_key_create'
/usr/lib/gcc/i486-slackware-linux/4.4.3/../../../libgtest.so: undefined 
reference to `pthread_getspecific'
/usr/lib/gcc/i486-slackware-linux/4.4.3/../../../libgtest.so: undefined 
reference to `pthread_key_delete'
/usr/lib/gcc/i486-slackware-linux/4.4.3/../../../libgtest.so: undefined 
reference to `pthread_setspecific'
collect2: выполнение ld завершилось с кодом 
возврата 1
make[3]: *** [test/prgnm-test] Ошибка 1
make[2]: *** [test/CMakeFiles/prgnm-test.dir/all] Ошибка 2
make[1]: *** [test/CMakeFiles/check.dir/rule] Ошибка 2
make: *** [check] Ошибка 2

Yes, I know that target_link_libraries (prgnm-test  gtest pthreads) works fine. 

Original comment by intergal...@gmail.com on 27 Apr 2010 at 7:49

GoogleCodeExporter commented 9 years ago
Oops, target_link_libraries (prgnm-test  gtest pthread) of course.

Original comment by intergal...@gmail.com on 27 Apr 2010 at 7:55

GoogleCodeExporter commented 9 years ago
If you use CMake, the best way to handle this is to add 

add_subdirectory(<path_to_gtest_root>)

before you use the gtest library in your CMake script.

Original comment by vl...@google.com on 3 May 2010 at 4:27

GoogleCodeExporter commented 9 years ago
Closing, as we don't maintain FindGTest.cmake.

Original comment by vladlosev on 13 May 2010 at 8:54