Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake to place the intermediate files to a certain directory

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.

like image 582
user243655 Avatar asked Sep 03 '25 02:09

user243655


1 Answers

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.

like image 185
arrowd Avatar answered Sep 04 '25 15:09

arrowd