简体   繁体   English

设置我的源代码,建立目录并制作工具

[英]Setting up my source, build directories and make tool

I am trying to set up a new C++ project. 我正在尝试建立一个新的C ++项目。 I am trying to achieve the following: 我正在努力实现以下目标:

  1. Source is under ~/repo/source/ 来源在〜/ repo / source /下
  2. Built files go to ~/repo/build/... 内置文件转到〜/ repo / build / ...
  3. ~/repo/source should remain as clean as possible, at least I should be able to ignore any files that are written there using .gitignore entries 〜/ repo / source应该保持尽可能干净,至少我应该能够忽略使用.gitignore条目写入那里的任何文件
  4. I can build from any directory under ~/repo/source (eg I can call "mymake" from under ~/repo/source/project1/lib1), and it will build and put the binaries under ~/repo/build 我可以从〜/ repo / source下的任何目录构建(例如,我可以从〜/ repo / source / project1 / lib1下调用“ mymake”),它将构建二进制文件并将其放在〜/ repo / build下
  5. I can build debug or release binaries, and they go to their respective directories. 我可以构建调试或发布二进制文件,然后它们进入各自的目录。 eg "mymake --config=debug" or something similar. 例如“ mymake --config = debug”或类似的东西。

This seems like the setup I have seen in every tech company I have worked for. 这似乎是我在曾经工作过的每家科技公司中看到的设置。 I don't know enough about make tools though to do this. 我对制作工具还不甚了解。 Can I use cmake to achieve the above? 我可以使用cmake实现以上目标吗? Many thanks in advance. 提前谢谢了。

Can I use cmake to achieve the above? 我可以使用cmake实现以上目标吗?

yes: 是:

  1. - --
  2. Yes, assuming that your CMakeLists.txt is in ~/repo/source/ , you run either cmake ../source from ~/repo/build/ (or absolute path) dir or use the gui with that path. 是的,假设您的CMakeLists.txt位于~/repo/source/ ,则可以从~/repo/build/ (或绝对路径)dir运行cmake ../source或将gui与该路径一起使用。 But normaly the build is placed within your project ( ~/repo/source/build ) and eg. 但是通常情况下, build会放置在您的项目( ~/repo/source/build )中,例如。 added to git ignore since it's not designated for sharing. 由于未指定共享,因此添加到git ignore中。 Just run cmake .. from there. 从那里运行cmake ..
  3. No problem, all local / generated files are within the build dir (see #2); 没问题,所有本地/生成的文件都在build目录中(请参阅#2); add this to .gitignore . 将此添加到.gitignore For sharing your project: just don't share build . 对于共享您的项目:只是不共享build
  4. You have to run cmake with the path where your root CMakeLists.txt is. 您必须使用根CMakeLists.txt所在的路径运行cmake。 But: child-dirs can have their own lists. 但是:child-dirs可以有自己的列表。
  5. Yes. 是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Make 从 Linux 中的两个源目录构建 c++ 项目 - build c++ project using Make from two source directories in Linux 将多个源目录构建到同一目标目录中 - Build multiple source directories into the same target directory 列出/设置使&C ++搜索头文件的目录 - Listing/setting directories that make & C++ search for header files 使用我自己的源目录生成vs2010项目文件 - generate vs2010 project file with my own source directories 隐式构建规则:GNU使多个Makefile成为多个目录 - Implicit Build Rules: GNU Make Multiple Makefiles Multiple Directories 为 Visual Studio 2017 设置 Curl:NMAKE:致命错误 U1073:不知道如何制作 '..\\src\\tool_hugehelp.c' - Setting up Curl for Visual Studio 2017: NMAKE: fatal error U1073: don't know how to make '..\src\tool_hugehelp.c' make:建立一个复杂的先决条件清单 - make: setting up a complex prerequisit list 在Heroku上设置OSRM(开源路由机器) - Setting up OSRM (Open Source Routing Machine) on Heroku SQLite-从源代码构建库或将源代码直接包含到我的projet中 - SQLite - build library from source or include source directly into my projet 是什么导致我的 ATLAS 工具在尝试构建时失败? - What is causing my ATLAS tool to fail when trying to build?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM