How to add external projects to CMake when the project repo is not the root of the library that I want to use, but actually contains two directories, which are the root directories of the repositories that I want to use in my project?
I'm working on creating a CMake project that uses Google Test and Mock for testing, however, when I try to download the google test repo ( https://github.com/google/googletest ) from ExternalProject_Add , it complains about the build that it cannot find source for the project. Well, this is because Google combined googletest and googlemock into one project, with the exception of two projects.
Some repo file structure:
googletest-master/ βββ[...no CMakeFiles.txt exists here...] βββgoogletest/ β βββsrc/ β βββCMakeFiles.txt βββgooglemock/ βββsrc/ βββCMakeFiles.txt
When I do the following ...
ExternalProject_Add( gtest GIT_REPOSITORY https://github.com/google/googletest.git TIMEOUT 10 INSTALL_COMMAND "" LOG_DOWNLOAD ON LOG_CONFIGURE ON LOG_BUILD ON PREFIX "googletest-master" )
... it uploads the actual repo to googletest-master/src/gtest , because I prefix the repo with "googletest-master" to save it from my main source code, and assumes that I load a project that is source only and this one The source is in the root directory.
So, I would like to do two things:
- Upload the repo to the googletest-master directory, just as if I cloned the repo there or downloaded the zip from GitHub and extracted it.
- Create and include both googletest and googlemock in my CMake project
source share