TheGOro / googletest

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

Add support and docs for building user's tests with CMake #372

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
NB: I'm not very familiar with CMake, just wanted to add googletest to one 
CMake-based project.

So, the goal set up is as follows:
1) ./tests <- directory that stores the tests sources
2) ./third_party/googletest <- svn external with the googletest sources
Ideally, "./" shall know nothing about googletest.

I've tried using codesearch for "googletest file:CMakeLists.txt" and it turns 
out every project writes its own solution to the "find and use googletest" 
quest.
Some of them tend to use gtest installed in /usr/local/include but looks like 
it doesn't contain any .cmake files (right?)

As my colleague told me, one can put a XXXConfig.cmake file into the project 
root directory (e.g. third_party/googletest) and then use it with the following 
commands:
  SET(XXX_DIR third_party/googletest)   # e.g. XXX = GoogleTest
  FIND_PACKAGE(XXX)

Original issue reported on code.google.com by timurrrr@google.com on 6 Jun 2011 at 3:13

GoogleCodeExporter commented 9 years ago
The GoogleTestConfig.cmake file should set up the library and include paths and 
have a copy of internal_utils.cmake file, which when used via FIND_PACKAGE 
makes those util functions/macros available for the user's CMakeLists.txt file. 
 Ideally there would be a build rule added to the existing cmake support for 
building the gtest libs themselves that creates this GoogleTestConfig.cmake 
file and points at the build dir for the libs to support using a locally-built 
gtest.

Original comment by bruen...@google.com on 6 Jun 2011 at 3:26

GoogleCodeExporter commented 9 years ago
The official position is to have your CMake file refer to Google Test's one, 
set appropriate flags, and use the library targets defined by Google Test 
directly. See the discussion in 
https://groups.google.com/d/topic/googletestframework/zHy-rrKz_Ho/discussion 
for more info. It is a good idea to put it into a more prominent place like a 
README, though.

Original comment by vladlosev on 6 Jun 2011 at 6:49

GoogleCodeExporter commented 9 years ago
Thanks Vlad!
Having it in the README would be indeed useful.

Original comment by timurrrr@google.com on 7 Jun 2011 at 9:12