Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

[CMake] [CPack] Preprocess or postprocess for make package* targets

CPack can pack source and binary accourding to
CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR, CPACK_PACKAGE_VERSION_PATCH
and CPACK_SOURCE_IGNORE_FILES, CPACK_PACKAGE_IGNORE_FILES in CMakeLists.txt.

CMake then produce targets like package, package_source, however,
CMake itself does not recognize the these targets. So we cannot associate and
depend any targets by either ADD_CUSTOM_COMMAND() or
ADD_DEPENDENCIES()

, in other words, CMake does not recognize package, package_source itself.

But what if you do want to associate some commands and targets before or after the package is built?
Here is some quick hack: Use a target: pack_src for package_source,
just like:

ADD_CUSTOM_TARGET(pack_src
    COMMAND make package_source
    COMMENT "Packaging Source files"
    DEPENDS other_dependency 
    VERBATIM
    )

Note that I have to add package_source, as CMake does not recognize package_source, and I need to call it explicitly.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: