将标题/库/可执行文件移动到特定目录 [英] Moving Headers/Libraries/Executables to specific directories

查看:117
本文介绍了将标题/库/可执行文件移动到特定目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在我的一个多平台项目中使用CMake,但是我在处理某些事情时遇到了一些麻烦。

I've recently started using CMake for one of my multi-platform projects, but I'm having a little trouble figuring out how to do something.

基本上,在项目内部我有多个库和可执行文件,都在自己的文件夹中。我想把所有的编译库放在一个目录下的构建,即一个lib文件夹内的CMake build文件夹。我想为可执行文件做同样的事情。

Basically, inside the project I've got multiple libraries and executables, all in their own folders. I would like to place all of the compiled libraries into one directory on build i.e. a lib folder inside the CMake build folder. I would like to do the same things for the executables.

CMake Build Directory

| ----------> bin (where i want the executables to go)

| ----------> lib (where i want the libraries to go)

| ----------> utils (where the libraries are ordinarily compiled)

| ----------> test (where the executables are ordinarily compiled)

在utils和apps中有所有不同库和我可以执行的。我有一个CMakeLists在我的源目录的基本文件夹,添加所有的子目录。

There are directories inside utils and apps for all the different libraries and executables I'm making. I have a CMakeLists in the base folder of my source directory which adds all the subdirectories. If anything does not make sense then feel free to ask.

推荐答案

您也可以使用:

  set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
  set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
  set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )

这篇关于将标题/库/可执行文件移动到特定目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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