[CMake] Custom command behavior
Alexander Broekhuis
a.broekhuis at gmail.com
Tue Nov 15 08:04:00 EST 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111115/3361b5df/attachment.htm>
More information about the CMake
mailing list