[CMake] CPack change file extension

Kristian kristianonline28 at gmail.com
Fri Aug 26 14:22:22 EDT 2016


> Do you have any special reason why your rename target depends on PACKAGE,
is this the target which cpack is using?

I think so ...

2016-08-26 20:01 GMT+02:00 tonka3100 at gmail.com <tonka3100 at gmail.com>:

> Hey Kristian,
>
> Thx for your answer. Iv've already done this like in your solution. I have
> a seperated target which depends on my create zip target and use
> ${CMAKE_COMMAND} -e copy to copy the file to my target directory (so the
> solution is platform independent), and leaf the original zip in the binary
> directory.
>
> Do you have any special reason why your rename target depends on PACKAGE,
> is this the target which cpack is using?
>
> Am 26.08.2016 um 19:05 schrieb Kristian <kristianonline28 at gmail.com>:
>
> Hey,
>
> you're working on Windows, right?
>
> I think you can do that if you create an additional target and call that
> target. So let's say, you have this 'hello.cpp', and you generate with
> CMake a solution. This is an example of a CMakeLists.txt
>
> > cmake_minimum_required(VERSION 3.4)
> > project(cpack_zip_test)
>
> > set(SOURCES hello.cpp)
>
> > add_executable(${PROJECT_NAME} ${SOURCES})
>
> > set(CPACK_GENERATOR "ZIP")
> > set(CPACK_PACKAGE_EXECUTABLE ${PROJECT_NAME})
> > set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-package)
>
> > add_custom_target(rename_zip
> > COMMAND rename ${CPACK_PACKAGE_FILE_NAME}.zip
> ${CPACK_PACKAGE_FILE_NAME}.docx
> > WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
>
> > include(CPack)
>
> When I call now something like this on the command line (Visual Studio 12
> 2013)
>
> > devenv cpack_zip_test.sln /Rebuild Debug /project PACKAGE.vcxproj
>
> and afterwards some like this
>
> > devenv cpack_zip_test.sln /Rebuild Debug /project rename_zip.vcxproj
>
> then this is some way of renaming your zip into a docx file. But I do not
> know, if there is a more automatic way to do this. I tried it with an
> additional parameter in the 'add_custom_target'-command (see at the DEPENDS
> part):
>
> > add_custom_target(rename_zip
> >     COMMAND rename ${CPACK_PACKAGE_FILE_NAME}.zip
> ${CPACK_PACKAGE_FILE_NAME}.docx
> > DEPENDS PACKAGE
> > WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
>
> But when I call 'devenv cpack_zip_test.sln /Rebuild Debug /project
> rename_zip.vcxproj', I would assume, that first the PACKAGE target is
> called, and afterwards the 'rename_zip' target is called. But that's not
> the case. Maybe some other person can tell me, if this is a bug or this is
> intention...
>
> 2016-08-24 21:53 GMT+02:00 tonka3100 at gmail.com <tonka3100 at gmail.com>:
>
>> Hey everybody,
>>
>> I try to rename the fileextension of my cpack zip file. So i use cpack -G
>> ZIP to create the package and get my zip file. Now i need to rename these
>> fileextension to another name, like microsoft did it with with docx word
>> format, where the file is a zip file, but has the docx extension.
>>
>> Does anybody know how i can do that?
>>
>> Greetings
>> Tonka
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160826/b59256a9/attachment-0001.html>


More information about the CMake mailing list