Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6254055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:07:27+00:00 2026-05-24T14:07:27+00:00

tl;dr version: Is it possible with CMake (>= 2.8) to generate zip files from

  • 0

tl;dr version:

Is it possible with CMake (>= 2.8) to generate zip files from some files and put the packed zip file in a specific location?

longer version:

I have a CMakeLists.txt that builds my project into a .exe file, and this exe file will read data from a zip file. The content to be packed in the zip file is in my git repository so that it can be edited, too. But, the program needs this data in a zip file. So it would be good if the CMake script could take the data, put it in a zip file, and place it next to the exe. I already heard of CPack, but I did not find any easy examples and am not sure if this is even the right tool for my task.

Is this possible? If yes, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:07:27+00:00Added an answer on May 24, 2026 at 2:07 pm

    For CMake 3.18 or newer use the ARCHIVE_CREATE file command. It supports both the creation of zip and 7zip archives.

    For example, if the current CMake source directory contains the file testfile.txt and the directory testdir, you can use the following CMake commands to create a zip file containing both items:

    file(ARCHIVE_CREATE
        OUTPUT "archive.zip"
        PATHS 
            "${CMAKE_CURRENT_SOURCE_DIR}/testfile.txt"
            "${CMAKE_CURRENT_SOURCE_DIR}/testdir"
        FORMAT "zip")
    

    For earlier versions of CMake (3.2 – 3.17) use the CMake command-line mode sub-command tar instead:

    add_custom_target(create_zip COMMAND
        ${CMAKE_COMMAND} -E tar "cfv" "archive.zip" --format=zip
           "${CMAKE_CURRENT_SOURCE_DIR}/testfile.txt"
           "${CMAKE_CURRENT_SOURCE_DIR}/testdir")
    

    For CMake versions earlier than 3.2, you can use the jar command that is part of a standard Java JRE installation.

    find_package(Java)
    
    execute_process(
        COMMAND
            "${Java_JAR_EXECUTABLE}" "cfM" "archive.zip" 
            "-C" "${CMAKE_CURRENT_SOURCE_DIR}" "testfile.txt" 
            "-C" "${CMAKE_CURRENT_SOURCE_DIR}" "testdir"
        RESULT_VARIABLE _result
    )
    

    The zip file will be generated in the current CMake binary dir (CMAKE_CURRENT_BINARY_DIR).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short version: I'm wondering if it's possible, and how best, to utilise CPU specific
Possible Duplicate: Make iPhone app paid version replace free version on install from app
is it possible to use Mercurial version control to track Word or PDF files?
Possible Duplicate: Version control for VBA file Does any kind of version control exist?
I have a problem with web service connection. It says, Possible SOAP version mismatch:
Possible Duplicate: jquery-min version? These two files are already included while creating a new
Is it possible to check the minor version number of GCC in cmake? I
Short version : Is it possible or not to use impersonation in ASP.NET to
Short version: Is it easy/feasible/possible to program modal window in Flash (AS3)? Is there
Is it possible to use BugzScout in the fogcreek-hosted version of Fogbugz?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.