cmake将中间文件放置到某个目录 [英] cmake to place the intermediate files to a certain directory

查看:2547
本文介绍了cmake将中间文件放置到某个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的cmake和奇迹,我怎么能这样做是cmake。我想把所有的中间文件(如.o文件)放在某个目录(比如build),然后一旦构建完成后,我想复制某些文件我需要(例如.exe,。 dll就像最终产品一样)从build目录到stage目录。如何指定这两个目录的路径(构建和阶段)? Cmake还将检查build / stage目录是否存在。如果不存在,它将为我创建目录。



任何帮助将不胜感激。

解决方案

您要求的是最常见的CMake用例。



为了使整个构建过程发生在任意目录,



您的来源(或使用cmake-gui) cmake / path / to / your / project



至于第2点:



您应该将 install()调用放入CMakeLists.txt(参见 install()文档),并将CMAKE_INSTALL_PREFIX设置为您希望文件复制的目录。之后,您可以从您的构建目录中运行 make install cmake -P cmake_install.cmake 来安装这些文件。 / p>

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.

解决方案

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.

这篇关于cmake将中间文件放置到某个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆