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

Patrick Johnmeyer pjohnmeyer+cmake at gmail.com
Thu Feb 14 12:21:40 EST 2013


Here's a follow-up.

I was unable to get Jean-Christophes modification of Ansis' solution
working. (I definitely did not want to repeat the install directives in
this rather large project.) The "-DCMAKE_BUILD_TYPE" lines don't really
accomplish anything when building with Visual Studio. I was making progress
but ultimately gave up. Here is where I stopped.

#####
include(ExternalProject)

ExternalProject_Add(MyProjectDebug
  PREFIX Debug
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
  CMAKE_ARGS -G ${CMAKE_GENERATOR} -D CMAKE_BUILD_TYPE=Debug -D
CPACK_BUILD_CONFIG=Debug
  BUILD_COMMAND "${CMAKE_COMMAND}" --build
${CMAKE_BINARY_DIR}/Debug/src/MyProjectDebug-build --config Debug
  )

ExternalProject_Add(MyProjectRelease
  PREFIX Release
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
  CMAKE_ARGS -G ${CMAKE_GENERATOR} -D CMAKE_BUILD_TYPE=Release -D
CPACK_BUILD_CONFIG=Release
  BUILD_COMMAND "${CMAKE_COMMAND}" --build
${CMAKE_BINARY_DIR}/Release/src/MyProjectRelease-build --config Release
  )


set(CPACK_INSTALL_CMAKE_PROJECTS
  "${CMAKE_BINARY_DIR}/Debug/src/MyProjectDebug-build;MyProject;ALL;/"
  "${CMAKE_BINARY_DIR}/Release/src/MyProjectRelease-build;MyProject;ALL;/"
)

include(CPack)
#####

At this point, the debug build would build in the debug tree and the
release build in the release tree. All is well to that point. However, when
I would attempt to use CPack with no -C option it would attempt to package
Debug from the Release tree. When I would attempt to use CPack with a -C
option, it would fail on one or the other (whichever one I did not specify).

I tried a slight fork of the above using the NMake generator instead of the
Visual Studio 10 generator but still ran into some issues local to our
CMake files. I may try to resolve that next, but if anybody has any hints
of where go from here that would be appreciated.

Frankly it seems to me that we should be able to package multiple configs
without any of this extra work.


On Fri, Feb 8, 2013 at 2:50 AM, Yngve Inntjore Levinsen <
yngve.levinsen at gmail.com> wrote:

>
> On 7/2/13 7:54 PM, Patrick Johnmeyer wrote:
>
> On Thu, Feb 7, 2013 at 12:41 PM, Yngve Inntjore Levinsen <
> yngve.levinsen at gmail.com> wrote:
>
>>  I think you are fighting the tool in any case, because you are asking to
>> build multiple configurations in one build folder (?). Normally you would
>> create one build folder per configuration.. Which I guess is what you are
>> doing today.
>>
>
> No, the Visual Studio generator is not a "*single-configuration generator"
> *. all configurations are bundled into the single generated solution
> file. This is the standard behavior of CMake under "basic" usage.
>
>  Your solution using ExternalProject looks promising, though, I will try
> this out. Thanks!
>
> Aha, I have mostly used the Makefile generator, and never VS, so I didn't
> know that. I agree, the externalproject trick proposed by Ansis sounds
> better. Good luck!
>
> Cheers,
> Yngve
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130214/179a7984/attachment.htm>


More information about the CMake mailing list