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

  • Home
  • SEARCH
  • 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 6040641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:32:38+00:00 2026-05-23T06:32:38+00:00

I’m very new to CMake but have experience with general build environments like Make.

  • 0

I’m very new to CMake but have experience with general build environments like Make.

Our project structure is like the following:

   $ROOT\cpp\bindings\ruby
   $ROOT\cpp\bindings\ruby\ext
   $ROOT\cpp\src
   $ROOT\cpp\include

We use swig to generate Ruby bindings for our C++ library. I want to now copy the source code generated by swig ($ROOT\cpp\bindings\ruby\rubyRUBY_wrap.cxx) along with the headers in $ROOT\cpp\include into the directory $ROOT\cpp\bindings\ruby\ext. Then I can have our build environment package all of that together as a GEM for distribution.

I can’t seem to find an example online of how to do this in CMake and would appreciate an assist. How do I copy a generated file plus a known directory to a location?

  • 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-23T06:32:39+00:00Added an answer on May 23, 2026 at 6:32 am

    In your case, I’d rather add a special target for distribution, and include a special CMakeLists.txt file (or another build system, like Autotools) in the resulting archive. Something like this, supposing you have CMakeLists.txt in your $ROOT/cpp:

    set (dist_gem_name package-gem-1.2.3)
    add_custom_target (dist_gem
        COMMAND ${CMAKE_COMMAND} -E  # Create a working directory.
            make_directory ${dist_gem_name}
        COMMAND ${CMAKE_COMMAND} -E  # Copy a build system in there.
            copy ${CMAKE_SOURCE_DIR}/CMakeLists-gem.txt ${dist_gem_name}
        COMMAND ${CMAKE_COMMAND} -E  # Copy the source file.
            copy ${CMAKE_SOURCE_DIR}/bindings/ruby/rubyRUBY_wrap.cxx ${dist_gem_name}
        COMMAND ${CMAKE_COMMAND} -E  # Copy the directory with header files.
            copy_directory ${CMAKE_SOURCE_DIR}/include ${dist_gem_name}
        COMMAND ${CMAKE_COMMAND} -E  # Create a distribution archive.
            tar czf ${dist_gem_name}.tgz ${dist_gem_name}
        COMMAND ${CMAKE_COMMAND} -E  # Dispose of our directory.
            remove_directory ${dist_gem_name}
        DEPENDS ${CMAKE_SOURCE_DIR}/bindings/ruby/rubyRUBY_wrap.cxx
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
    

    As you can see, you can do this type of things with cmake -E. If you want to run such things during the configure part, use execute_process. If you want to see the list of available commands, just run cmake -E with no further parameters.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.