使用CMake设置C ++目标文件的输出位置 [英] Set C++ object file output location with CMake

查看:690
本文介绍了使用CMake设置C ++目标文件的输出位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在项目中使用CMake,但我有以下两个要求:

I would like to use CMake for a project, but I have the following two requirements:


  1. 项目的最终输出应为是一组目标文件(* .o)。

  2. 目标文件的位置很重要。我想选择文件输出到哪个目录。

CMake是否支持这种类型的行为?如果是这样,怎么办?建立目标文件后,可以使用move命令执行此操作吗?

Does CMake support this type of behavior? If so, how? Can I do it with move commands after the object file is build?

推荐答案

首先创建对象库

现在的问题是:


对象库无法导入,导出,安装或链接。
http://www.cmake.org /cmake/help/v2.8.11/cmake.html#command:add_library

我会尝试使用< a href = http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command%3ainstall rel = nofollow>安装(目录...)。

使用选项:

DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}   #Probably you have to check more precisely where the object files are built

DESTINATION    #it's something relative to DESTDIR, if set, or CMAKE_INSTALL_PREFIX otherwise

FILES_MATCHING

PATTERN "*.o"

此解决方案的一个缺点是在输出目录名称中,即将基本上由cmake决定,我想知道在这方面是否可以做任何事情。

A flaw of this solution will be in the output directory name, that will be basically decided by cmake, I wonder if anything can be done in that respect.

这篇关于使用CMake设置C ++目标文件的输出位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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