[CMake] Top level target depending on a file

Alexander Broekhuis a.broekhuis at gmail.com
Tue Dec 13 04:13:46 EST 2011


Hi,


> The only issue would be that you have to "call" (i.e. build) the new
> custom target explicitely instead of relying on POST BUILD.
>

I had hoped it would be as simple as adding a DEPENDS to the custom target,
or something similar.

>
> Note that may be I didn't catch your usage so may be you can
> send us the concerned bits of your CMakeLists.txt
>

What I have is a macro which takes care of adding a library, this library
is wrapped in a zip file using CPack. Together with the library there is a
manifest file which needs to be added to the zip file.

I would like to be able to track changes to this manifest file and trigger
an out-of-date so that the zip is is recreated when building again.

The macro I use:

=======
MACRO(bundle)
    PARSE_ARGUMENTS(BUNDLE "SOURCES;FILES;DIRECTORIES" "" ${ARGN})
    LIST(GET BUNDLE_DEFAULT_ARGS 0 BUNDLE_NAME)

    add_library(${BUNDLE_NAME} SHARED ${BUNDLE_SOURCES})
    install (DIRECTORY META-INF DESTINATION . COMPONENT ${BUNDLE_NAME})
    install (TARGETS ${BUNDLE_NAME} DESTINATION . COMPONENT ${BUNDLE_NAME})

    if (BUNDLE_FILES)
        install (FILES ${BUNDLE_FILES} DESTINATION . COMPONENT
${BUNDLE_NAME})
    endif(BUNDLE_FILES)

    if (BUNDLE_DIRECTORIES)
        install (DIRECTORY ${BUNDLE_DIRECTORIES} DESTINATION . COMPONENT
${BUNDLE_NAME})
    endif(BUNDLE_DIRECTORIES)

    SET(__bundleConfig
${CMAKE_CURRENT_BINARY_DIR}/CPackConfig-${BUNDLE_NAME}-bundle.cmake)
    SET(BUNDLE_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/CPackConfig.in
${__bundleConfig} @ONLY)
    ADD_CUSTOM_COMMAND(TARGET ${BUNDLE_NAME}
        POST_BUILD
        COMMAND ${CPACK_COMMAND} ARGS --config ${__bundleConfig}
        WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/bundles
    )
    SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
${PROJECT_BINARY_DIR}/bundles/${BUNDLE_NAME}.zip)
ENDMACRO(bundle)


-- 
Met vriendelijke groet,

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


More information about the CMake mailing list