[CMake] Rename the output of cpack

Tyler tyler at cryptio.net
Tue May 17 15:31:24 EDT 2011

Ah, yes. If only we could add dependencies and pre-/post-build
commands to built-in CMake targets...

Absent that, the best I can think of is to just write a custom command
that renames ${CMAKE_BINARY_DIR}/your_package.extension. (I don't know
of a way to query the build system for what the full name will be,
including extension. I maintain my own mapping of CPACK_GENERATOR to
extension (STGZ -> .sh, NSIS -> .exe, etc.)).

If you want to hook it up automatically, you could write your own
version of the package target that just calls cpack itself in
${CMAKE_BINARY_DIR}. That target could have a post-build rule that
does the rename.

Maybe someone else has better ideas but that's the hack that springs to mind.


On Tue, May 17, 2011 at 11:18 AM, James Bigler <jamesbigler at gmail.com> wrote:
> CPack allows me to configure the basename of the package, but I would like
> to be able to change the extension used.  I dug around the CPack sources and
> it looks like the file extension is baked into the 'virtual const char*
> GetOutputExtension() { return ".sh"; }' function.  It doesn't look like I
> can configure it, so I'm trying to see if there is a way to rename the file
> after it's been generated.  Kind of like a post-link command.  Does anyone
> know how I could do this?
> Thanks,
> James
> _______________________________________________
> Powered by www.kitware.com
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

More information about the CMake mailing list