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?
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:
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, useexecute_process. If you want to see the list of available commands, just runcmake -Ewith no further parameters.