[CMake] CPack: Adding a file to package_source target

Adolfo Rodríguez dofo79 at gmail.com
Fri Feb 6 10:06:52 EST 2009


After messing around with the issue, I have -almost- succeeded in
accomplishing what I wanted. Right now, I'm installing the top-level
CMakeLists.txt file by setting:

set(CPACK_INSTALL_COMMANDS "${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/CMakeLists.txt
{CMAKE_BINARY_DIR}/_CPack_Packages/Linux-Source/TGZ/${CPACK_SOURCE_PACKAGE_FILE_NAME}")

Now two issues remain to be solved:
- I want the above command to be called only when building source packages,
so is there a flag that I can use to wrap it in a if() clause? (something
like CPACK_BUILD_SOURCE_PACKAGE or similar)

- There is one part of the destination path that is currently hardcoded,
namely "_CPack_Packages/Linux-Source/TGZ". Are there any CPack variables
that contain this information?, especially the
"_CPack_Packages/Linux-Source" part. I printed the values of all cmake
variables and grepping for these strings and found nothing (except for my
hardcoded lines :-P ).

In case this is relevant, I'm using cmake 2.6.0, and these are the
CPACK-related variables that I set before calling include(CPack):

set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY  "${PROJECT_NAME} project")
set(CPACK_PACKAGE_FILE_NAME            "${PROJECT_NAME}-${brief_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-source-${brief_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY    "${PROJECT_NAME}-${brief_VERSION}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME}-${brief_VERSION}")
set(CPACK_PACKAGE_NAME                 "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR               "XXXX")
set(CPACK_PACKAGE_VERSION              "${${PROJECT_NAME}_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR        "${${PROJECT_NAME}_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR        "${${PROJECT_NAME}_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH        "${${PROJECT_NAME}_VERSION_PATCH}")

# General setup
set(CPACK_PACKAGE_RELOCATABLE "true")
set(CPACK_SOURCE_INSTALLED_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src;./src;${CMAKE_SOURCE_DIR}/etc;./etc;")
set(CPACK_SOURCE_IGNORE_FILES
"/CVS/;/\\\\.svn/;\\\\.swp$;~$;\\\\.\\\\#;/\\\\#")
set(CPACK_INSTALL_COMMANDS "${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/CMakeLists.txt
${CMAKE_BINARY_DIR}/_CPack_Packages/Linux-Source/TGZ/${CPACK_SOURCE_PACKAGE_FILE_NAME}")

TIA,

Adolfo Rodríguez Tsouroukdissian

On Thu, Feb 5, 2009 at 5:08 PM, Adolfo Rodríguez <dofo79 at gmail.com> wrote:

> Hello,
>
> I have a project with the following structure:
>
> trunk
>   |-src
>   |-build_dir1
>   |-build_dir2
>   |-another_dir
>   |-CMakeLists.txt
>   |-unimportant_file
>   |-another_unimportant_file
>
> I am configuring CPack to make source packages. The content I'm interested
> in packaging is folder src (and all its contents) and the shown
> CMakeLists.txt file, and ignore everything else.
> I have successfully packaged src with
>
> set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR}/src;./src")
>
> and now I would like to include the CMakeLists.txt file. Since the trunk
> folder is full of many things I do not wish to install, I'd rather not use
> CPACK_SOURCE_IGNORE_FILES and specify a cunch of complex rules, but tell
> CPack to add an additional file. Is this possible?
>
> I was trying out CPACK_INSTALL_COMMANDS, but I haven't figured out how to
> use it, and the variable is AFAIK pretty much undocumented (either in the
> book or online).
>
> Any help would be much appreciated.
>
> Adolfo Rodríguez Tsouroukdissian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090206/eaaadf4d/attachment-0001.htm>


More information about the CMake mailing list