[CMake] Custom command behavior

Alexander Broekhuis a.broekhuis at gmail.com
Tue Nov 15 09:21:05 EST 2011


Hello,

I think I've already found the problem. In the custom command I run a CPack
script, and CPack triggers a full build of the project, which in turn again
triggers the custom command (and thus the CPack command).

Is it possible to make the CPack config so that only a specific target is
being build? I have a one on one relation between library and zip file, and
would like to be able to build one target and resulting zipfile.

Currently I am using a custom target, this also solves my problem, and
would be fine if it didn't build always. Is it possible to add some
up-to-date check to it?

2011/11/15 Alexander Broekhuis <a.broekhuis at gmail.com>

> Hi all,
>
> When using a custom command in a macro I see some strange behavior.
>
> The following setup is used:
> I have a macro, called "bundle", in this macro a custom command is added.
> This command uses a library as target, and executes cpack with a
> configuration. I use cpack to create a zip file inside my project with the
> library and additional resources.
>
> This macro is used with the name of a library. When running the library
> target (make {lib-name}), the command is executed for all usages of the
> macro, instead of only for the given target. If I change it to a custom
> target, and add that target to the library target using add_dependencies it
> is all ok, but a custom target is always out-of-date, which is something I
> would like to prevent.
>
> If I run the cpack command myself it is only executed once (as expected).
>
> What am I doing wrong here?
>
> TiA!
>
> ps: The macro I use:
> ------------------------
> macro(bundle)
>  PARSE_ARGUMENTS(BUNDLE "FILES;DIRECTORIES" "" ${ARGN})
>   LIST(GET BUNDLE_DEFAULT_ARGS 0 BUNDLE_NAME)
>   SET(__bundleConfig
> ${CMAKE_CURRENT_BINARY_DIR}/CPackConfig-${BUNDLE_NAME}-bundle.cmake)
>   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/CPackConfig.in
> ${__bundleConfig} @ONLY)
>
>   ADD_CUSTOM_COMMAND(TARGET ${BUNDLE_NAME}
>     POST_BUILD
>     WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/bundles
>
>     # This is an echo of the command. Running this myself on the command
> line works as expected
>     COMMAND echo ${BUNDLE_NAME} ${CPACK_COMMAND} --config
> "${__bundleConfig}"
>
>     # This is executed for each macro call I did
>     COMMAND ${CPACK_COMMAND} --config "${__bundleConfig}"
>   )
> endmacro(bundle)
> ------------------------
> --
> Met vriendelijke groet,
>
> Alexander Broekhuis
>



-- 
Met vriendelijke groet,

Alexander Broekhuis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111115/9a32eaed/attachment.htm>


More information about the CMake mailing list