[CMake] add_custom_target

Cameron Palmer cameron at promon.no
Fri Mar 2 06:22:14 EST 2018


I’m using ExternalProject_Add to download a Git project that is a pre-requisite of my project. For the sake of the discussion I’ve wrapped OpenSSL and Boost in this manner placing tagged version of the source in my repo.

Building them isn’t really a problem, they run, take a long time compiling. The thing is, they should only compile once unless the tag changes. From the source it seems once you’ve used git you’ll always trigger the whole External Build sequence which is a pain since it is slow. So… I’ve been trying to create an external build just for the Git checkout and a second for the compilation. Which goes well enough, but I still need the glue to signal that he source is ‘dirty’ and it should recompile the project.

The glue I’m trying to use is add_custom_command and add_custom_target, but add_custom_target seems… broken if only in concept. I’ve been trying to write a file to the system with the SHA tag and only touch it when it changes, but I cannot convince the ExternalProject that builds the library to not run.

Any tips that might make this work?


More information about the CMake mailing list