Add an external source directory to a CMake build

Viewed 11420

I'm using Google Mock for my project, and the instructions say it's better to build the library along with the project, because different compiler flags can introduce bugs. I don't want to add the gmock/ directory to my repository; I'd rather have the sources as an external dependency and plug it into my build process. Which brings me to my question: how can I instruct CMake to pull the external source directory into the build (i.e. build it in my project's build directory)? I found a similar question here, but the answers requires a rigid directory placement, and I'd rather have that configurable. Any other way to do it?

2 Answers
Related