Reputation: 8595
I am pretty new to cmake and wonder how I can do this is cmake. I want to place all the intermediate files (like the .o files) to be placed in a certain directory (say "build") and then once the build is done I want copy certain files I need (e.g., the .exe, .dll like the end product) from build directory to "stage" directory. how can I specify the path to these two directories (build and stage)? Cmake will also check if the build/stage directory exists or not. If does not exist, it will create the directories for me.
Any help will be appreciated.
Upvotes: 4
Views: 3384
Reputation: 7705
I would suggest another approach.
Or instead of choosing step 2 you also can provide an install routine where the needed executables are installed in a give path. see here
Upvotes: 1
Reputation: 34401
What are you asking is the most often CMake use case.
To make whole build process to occur in arbitary dir, you should run cmake /path/to/your/project
from that dir (or use cmake-gui).
Your source dir would be untouched until you explicitly tell CMake to output some files there.
As for point 2:
You should place install()
invocations into your CMakeLists.txt (see documentation on install()
) and set CMAKE_INSTALL_PREFIX to the dir where you wish files to be copied. After that you can run make install
or cmake -P cmake_install.cmake
from your build dir to install these files.
Upvotes: 2