What is the default build configuration of cmake

2019-02-18 20:32发布

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

But I have a different observation:

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)

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.

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

标签: c++ cmake
1条回答
混吃等死
2楼-- · 2019-02-18 21:12

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

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).

查看更多
登录 后发表回答