← Back to team overview

kicad-developers team mailing list archive

A useful CMake trick



Here is a technique that might be helpful someday.  I found this article (blog post) helpful, because it advances a
CMake external project build step into the configure phase up out of the baseline project build phase.  It is summarized
by the last paragraph in the blog post:


Generalising for any external project

There’s no inherent assumption in the above which restricts this approach to just gtest or gmock. It can be generalised
to support any external project which uses CMake as its build system. This essentially amounts to parameterising the
project name and the download, source and binary directories inside a CMake function. It can also be made to support
more than just git clone/checkout as a download method, it can easily support anything ExternalProject itself supports.
I’ve already gone ahead and done all the work for you, so just grab it from the Github project associated with this
article. It even includes a simple example with gtest and gmock test cases to show how to use it. Enjoy!