dingyichen (dingyichen) wrote,
  • Mood:

[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.</p>

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.

Tags: cmake, cpack
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

  • 0 comments