Definite's Extractor

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

About “Avoiding Packing junk in CPack/CMake”

One reader of mine suggested that I can posted my finding to Fedora Wiki, but I don’t know how. Would you kind enough to tell me where do I start, thanks.

Nevertheless, my previous post does not show the whole method of junk-filtering in CMake/CPack. Following example demonstrates how to use CPack in CMake:

### Package configuration
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "<project name>")
SET(CPACK_PACKAGE_VENDOR "<vendor name>")
SET(CPACK_GENERATOR "TGZ")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE
    ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
SET(CPACK_RESOURCE_FILE_LICENSE
    ${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LESSER)
SET(CPACK_PACKAGE_VERSION_MAJOR <PROJECT_VER_MAJOR>)
SET(CPACK_PACKAGE_VERSION_MINOR <PROJECT_VER_MINOR>)
SET(CPACK_PACKAGE_VERSION_PATCH <PROJECT_VER_PATCH>)
SET(COMMON_IGNORE_FILES "/CMakeFiles/" "/Testing/" "/.svn/" "/CVS/" "_CPack_Packages/" 
    ".cmake$" "~" ".swp" ".log" ".gz" ".directory$" "CMakeCache.txt")
SET(PRJ_COMMON_IGNORE_FILES ${COMMON_IGNORE_FILES} <PROJECT_SPECIFIC_IGNORE_FILES_PATTERN> )

SET(CPACK_SOURCE_IGNORE_FILES ${PRJ_COMMON_IGNORE_FILES} 
<FILES_PATTERN_THAT_YOU_DONT_WANT_TO_PUT_IN_SOURCE_TARBALL>)
SET(CPACK_PACKAGE_IGNORE_FILES ${PRJ_COMMON_IGNORE_FILES} <FILES_PATTERN_THAT_YOU_DONT_WANT_TO_PUT_IN_BINARY_TARBALL> )
SET(CPACK_SOURCE_GENERATOR "TGZ")

INCLUDE(CPack)

Note that COMMON_IGNORE_FILES,PRJ_COMMON_IGNORE_FILES are my own variable, you can choose the name you like.

After executed cmake <project dir> you can see the make targets by typing make help

......
... package
... package_source
......

Use make package for binary package, and
make package_source for source tarball.

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: