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

David Cole DLRdave at aol.com
Tue Mar 24 14:31:36 EDT 2015


How about:

    add_custom_target(custom-install DEPENDS xxx-install)

and

    cmake --build . --target custom-install

??

The problem is that you are adding a custom target with the name
"install" which is one that CMake generates for you. (Names to be
avoided are all, clean, install, package, help ... (maybe a few
others?))

I think this whole process should be unnecessary anyway, because the
install step of the ExternalProject runs as part of the overall build,
even with just a "cmake --build ." -- doesn't it?


HTH,
David C.


On Tue, Mar 24, 2015 at 2:21 PM, Bill Somerville <bill at classdesign.com> wrote:
> On 13/03/2015 14:06, Bill Somerville wrote:
>>
>> 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?
>
> No replies on this one. Am I asking something that can't be done or am I
> missing something obvious?
>>
>>
>> Regards
>> Bill Somerville.
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list