[CMake] CPack: Packaging debug and release configurations in a single zip

Clinton Stimpson clinton at elemtech.com
Thu Feb 7 14:01:15 EST 2013


On Wednesday, February 06, 2013 01:09:20 PM Patrick Johnmeyer wrote:
> I have looked through the CMake wikis and several mailing list threads that
> the following google search returned, and I have not found a definitive
> answer to my question.
> 
> [site:www.cmake.org/pipermail/cmake CPack multiple configurations in one
> package]
> 
> My team delivers debug and release libraries, built under Visual Studio. We
> would like to package the debug and release libraries in a single zip file.
> However, I can only figure out how to get CPack to generate the zip for one
> configuration at a time. I could merge the two zip files after the fact,
> but it seems to me that there must be an easy way to get CPack to do this.
> Is there?
> 
> Regards,
> pj

Here's one way I've done it.

option(CREATE_MULTI_CONFIG_PACKAGE "Enable creating a multi-config package with 
both debug and release (doubles compile time)" OFF)


if(CREATE_MULTI_CONFIG_PACKAGE)

  set up a secondary build tree at ${CMAKE_BINARY_DIR}/SecondaryBuildTree, 
passing cmake options from here down to the secondary tree to make them match

  I use execute_process to run cmake on the second tree and pass options down 
(which compiler, and project specific settings that the user can modify for the 
primary build tree).

add a custom target to build the second build tree by running "cmake --build"


  # tell cpack to install both projects
  set(CPACK_INSTALL_CMAKE_PROJECTS 
    # self project
      "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/"
    # other config project
      "${CMAKE_BINARY_DIR}/SecondaryBuildTree;${CMAKE_PROJECT_NAME};ALL;/"
      )
endif()


-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com


More information about the CMake mailing list