0

I am in the process of moving an existing C++ build system to CMake and I have a question regarding External Project dependencies.

The scenario is that we have two projects A and B.

Project A pulls in googletest as an external project with the below command:

ExternalProject_Add(gtest
  GIT_REPOSITORY    git@github.com:google/googletest.git
  GIT_TAG           "release-1.8.1"
  SOURCE_DIR        "${CMAKE_BINARY_DIR}/gtest-src"
  BINARY_DIR        "${CMAKE_BINARY_DIR}/gtest-build"
  CONFIGURE_COMMAND ""
  BUILD_COMMAND     ""  
  INSTALL_COMMAND   ""  
  TEST_COMMAND      ""  
)

Note that project A depends on release-1.8.1 of googletest.

Now, project B pulls in googletest with the same command but depends on release-1.7.0 (different than the dependency of project A) AND project B also pulls in project A as another External Project.

Does this create some kind of collision between googletest versions when we run cmake on project B?

miles.sherman
  • 171
  • 3
  • 11
  • `Does this create some kind of collision between googletest versions when we run cmake on project B?` - Assuming the projects use **different names** for the ExternalProject (the first argument to the function), it should be no problem to work with it. Having the same name in the external projects will trigger CMake error about identical targets names. BTW, what about simply trying instead of asking about possible conflicts? – Tsyvarev Apr 19 '19 at 20:10
  • You’re right I’m being quite lazy not just trying it but I’m away from computer until next week. Thanks for the response. So if my project A and project B both try to link to a library within gtest, will that library be built twice and possibly with different code? – miles.sherman Apr 19 '19 at 21:32
  • Yes, ExternalProject will build two instances of the library in the different places. (Assuming its `SOURCE_DIR` parameters are different, the same for `BINARY_DIR`). – Tsyvarev Apr 19 '19 at 22:08
  • i got a chance to try this out. i am getting cmake errors because the two instantiations of googletest try and create the same targets (which is a name collision) – miles.sherman Apr 19 '19 at 22:56

0 Answers0