Hi all,<br><br>When using a custom command in a macro I see some strange behavior.<br><br><div>The following setup is used:<br>I have a macro, called &quot;bundle&quot;, 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.<br>
<br>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.</div>
<div><br></div><div>If I run the cpack command myself it is only executed once (as expected).</div><div><br></div><div>What am I doing wrong here?</div><div><br></div><div>TiA!</div><div><br></div><div>ps: The macro I use:<br>
------------------------<br>macro(bundle)<br>  PARSE_ARGUMENTS(BUNDLE &quot;FILES;DIRECTORIES&quot; &quot;&quot; ${ARGN})<br>  LIST(GET BUNDLE_DEFAULT_ARGS 0 BUNDLE_NAME)<br>  SET(__bundleConfig ${CMAKE_CURRENT_BINARY_DIR}/CPackConfig-${BUNDLE_NAME}-bundle.cmake)<br>
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/CPackConfig.in ${__bundleConfig} @ONLY)</div><div><br>  ADD_CUSTOM_COMMAND(TARGET ${BUNDLE_NAME} <br>    POST_BUILD<br>    WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/bundles</div>
<div><br></div><div>    # This is an echo of the command. Running this myself on the command line works as expected<br>    COMMAND echo ${BUNDLE_NAME} ${CPACK_COMMAND} --config &quot;${__bundleConfig}&quot;</div><div><br>
</div><div>    # This is executed for each macro call I did<br>    COMMAND ${CPACK_COMMAND} --config &quot;${__bundleConfig}&quot;<br>  )<br>endmacro(bundle)</div><div>------------------------<br>--<br>Met vriendelijke groet,<br>
<br>Alexander Broekhuis<br></div>