问题描述
在 GCC 编译的项目中,
In a GCC compiled project,
- 如何为每种目标类型(调试/发布)运行 CMake?
- 如何使用 CMake 指定调试和发布 C/C++ 标志?
- 我如何表示主可执行文件将使用
g++和一个嵌套的库与gcc编译?
- How do I run CMake for each target type (debug/release)?
- How do I specify debug and release C/C++ flags using CMake?
- How do I express that the main executable will be compiled with
g++and one nested library withgcc?
推荐答案
使用 CMake,一般建议做一个 源外"构建.在项目的根目录中创建 CMakeLists.txt.然后从您的项目的根目录:
With CMake, it's generally recommended to do an "out of source" build. Create your CMakeLists.txt in the root of your project. Then from the root of your project:
mkdir Release
cd Release
cmake -DCMAKE_BUILD_TYPE=Release ..
make
对于Debug(再次从项目的根目录):
And for Debug (again from the root of your project):
mkdir Debug
cd Debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
Release/Debug 将为您的编译器添加适当的标志.还有 RelWithDebInfo 和 MinSizeRel 构建配置.
Release / Debug will add the appropriate flags for your compiler. There are also RelWithDebInfo and MinSizeRel build configurations.
您可以通过指定工具链来修改/添加标志文件,您可以在其中添加CMAKE_<LANG>_FLAGS_<CONFIG>_INIT 变量,例如:
You can modify/add to the flags by specifying a toolchain file in which you can add CMAKE_<LANG>_FLAGS_<CONFIG>_INIT variables, e.g.:
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-Wall")
有关详细信息,请参阅 CMAKE_BUILD_TYPE.
See CMAKE_BUILD_TYPE for more details.
至于你的第三个问题,我不确定你在问什么.CMake 应自动检测并使用适合您不同源文件的编译器.
As for your third question, I'm not sure what you are asking exactly. CMake should automatically detect and use the compiler appropriate for your different source files.
这篇关于CMake 中的调试与发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)