cmake的默认构建配置是什么 [英] What is the default build configuration of cmake

查看:171
本文介绍了cmake的默认构建配置是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

答案中,它说Debug是默认的cmake构建配置。

In this answer, it says Debug is the default cmake build configuration.

但是我有不同的看法:

我在CMakeLists.txt中有以下内容,可以根据当前版本选择调试和发行版本的lib配置。

I have following in my CMakeLists.txt to choose debug and release versions of a lib according to the current build configuration.

target_link_libraries(MyApp debug Widgets_d)
target_link_libraries(MyApp optimized Widgets)

似乎我在不区分-DCMAKE_BUILD_TYPE标志的情况下调用cmake时,使用的是小部件,而不是Widgets_d(当我删除小部件并尝试构建时,使抱怨lib不存在)。因此,这意味着默认情况下将优化构建配置,而不是调试。

It seems that when I invoke cmake without sepcifying -DCMAKE_BUILD_TYPE flag, Widgets is used instead of Widgets_d (When I delete Widgets and try to build, make complains that lib is not there). So that means by default the build configuration is optimized, not debug.

那么默认的构建配置实际上是什么?如果是调试,我的CMakelists.txt可能是什么问题?

So what actually is the default build configuration? If it is debug, what could be wrong with my CMakelists.txt?

推荐答案

optimized 关键字的.cmake.org / cmake / help / v3.0 / command / target_link_libraries.html rel = noreferrer> target_link_libraries ,这不是调试。

target_link_libraries with optimized keyword corresponds to all configurations, which are not debug.

尝试向其中添加 message(STATUS Build type:$ {CMAKE_BUILD_TYPE})您的CMakeLists.txt可以查看实际的构建类型(我想它应该为空)。

Try adding message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") to your CMakeLists.txt to see the actual build type (I suppose it should be empty).

这篇关于cmake的默认构建配置是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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