[CMake] How to execute an external project target as part of a standard target.

Bill Somerville bill at classdesign.com
Fri Mar 13 10:06:35 EDT 2015


Hi All,

I have a superbuild style project consisting of a few external projects. 
I wish to build the install target of one of them as part of the install 
target of the parent project. I had it working by adding a step target 
called install and adding a custom target to the parent project that 
depends on the child step target. E.g.

ExternalProject_Add (xxx
   SVN_REPOSITORY ${xxx_repo}
   CMAKE_ARGS
     -D CMAKE_INSTALL_PATH=<INSTALL_DIR>
   INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
   STEP_TARGETS install)

add_custom_target (install DEPENDS xxx-install)

This arrangement allowed me to 'cmake --build . --target install' and 
have the child project install target run.

Now CMake complains about policy CMP0037, because I cannot define a 
reserved target name, so it seems I cannot abuse the 'install' target by 
adding extra dependencies any more.

Is there a better way to link child and parent targets that doesn't 
invoke this error?

Regards
Bill Somerville.


More information about the CMake mailing list