CPack change file extension

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CPack change file extension

tonka tonka
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
Reply | Threaded
Open this post in threaded view
|

Re: CPack change file extension

Kristian
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 [hidden email] <[hidden email]>:
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


--

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
Reply | Threaded
Open this post in threaded view
|

Re: CPack change file extension

tonka tonka
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 <[hidden email]>:

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 [hidden email] <[hidden email]>:
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


--

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
Reply | Threaded
Open this post in threaded view
|

Re: CPack change file extension

Kristian
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 [hidden email] <[hidden email]>:
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 <[hidden email]>:

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 [hidden email] <[hidden email]>:
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



--

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
Reply | Threaded
Open this post in threaded view
|

Re: CPack change file extension

Eric Noulard
HI all,

package is a builtin target unless things have changed you cannot depend on a builtin target.

Personnally I would explicitely call CPack in my custom target in order to be sure that the zip is up-to-date.

e.g.:

# find a way to get path to cpack command in a portable way
get_filename_component(CPACK_COMMAND ${CMAKE_COMMAND} PATH)
set(CPACK_COMMAND ${CPACK_COMMAND}/cpack)

add_custom_target(package_docx
    COMMAND $(CPACK_COMMAND} -G ZIP
    COMMAND ${CMAKE_COMMAND} -E rename ${CPACK_PACKAGE_FILE_NAME}.zip ${CPACK_PACKAGE_FILE_NAME}.docx
    WORKING_DIRECTORY ${CMAKE_BUILD_DIR})

cmake -E rename will work on the same volume, copy will work accross volume.

note that your custom target should run in build dir in order to make cpack work as expected.

2016-08-26 20:22 GMT+02:00 Kristian <[hidden email]>:
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 [hidden email] <[hidden email]>:
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 <[hidden email]>:

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 [hidden email] <[hidden email]>:
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



--

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



--
Eric

--

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