-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why CMAKE_BUILD_TYPE is always Debug? #3821
Comments
I would like to add that I can't find the correct way to simply add more build types. The CMakeFiles I use have for instance ServRel or ToolRel as build types, which I can't access at all. |
Thanks for reporting this issue. Today we try to repro using a simple CMake Project, but we didn't repro it. We find that if we set the "CMAKE_BUILD_TYPE": "Release" in related configuration, and the -DCMAKE_BUILD_TYPE=Release displays on CMake output when configure the project. For further investigation, could you please share us a demo project with clear repro steps? We are looking forward to hearing from you. Thanks. ENV: |
@Evelyn-001 Hi, thanks for the reply. This gif looks okay, and maybe I need a little time to learn to use CMakePresets.json. Actually I begin to use CMake since about CMake 3.12 or before that. My previous trial was on a Apple M1 machine, which is not available now. I guess Ninja as generator is the key to reproduce. Here is the detail:
VSCode: Version: 1.90.0 {
"cmake.generator": "Ninja",
"cmake.pinnedCommands": [
"workbench.action.tasks.configureTaskRunner",
"workbench.action.tasks.runTask"
],
} CMakeLists.txt cmake_minimum_required(VERSION 3.29)
project(x)
message(STATUS "[x] CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
add_executable(x x.c) x.c: int main() {} CMake Configure output by |
@Evelyn-001 Using the aforementioned
{
"cmake.pinnedCommands": [
"workbench.action.tasks.configureTaskRunner",
"workbench.action.tasks.runTask"
]
}
I suggest removing the use of |
This issue reproduces with below Conditions:
ENV: |
@gcampbell-msft, if user do not explicitly specify a value for CMAKE_BUILD_TYPE when executing CMake, or do not explicitly set it before building, will CMake choose a default CMAKE_BUILD_TYPE of Debug? Coud you please help look at this issue? Thanks in advance. |
@Evelyn-001 Yes, if there is no CMAKE_BUILD_TYPE specified, then the default is Debug. |
😂😂 Could you please drop this default "Debug"? I think this "Debug" may sometimes become a "Bug" in my C/C++ projects |
@zchrissirhcz @Evelyn-001 Let me take some time to investigate, I actually believe I may have been wrong about our default, let me look more closely into it and get you the full understanding and context. Thanks! |
@zchrissirhcz Okay I've investigated closer and we do in fact default to "Debug". What are you expecting the default to be? I'm guessing simply an empty string? |
@zchrissirhcz Follow up to help us understand your scenario better, is there a reason that you don't want to explicitly set the build type? |
I think cmake_minimum_required(VERSION 3.5)
projet(x)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
message(STATUS "[x] CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") When invoked in command like: cmake -S . -B build it will print But when invoked in VSCode CMake Tools' "cmake configure", it prints I see this usage in:
|
@gcampbell-msft An empty string ( If user do specify |
@zchrissirhcz Thanks for all of this information, we will definitely assess this on the backlog and investigate. Again, thanks! |
12bc6cdb375f9688ba2eff535c36b26dbbaff710 |
Brief Issue Summary
CMake: Configure
always uses-DCMAKE_BUILD_TYPE:STRING=Debug
even if I deleteCMAKE_BUILD_TYPE
or setCMAKE_BUILD_TYPE=Release
in setting of CMake Tools extension, and I've already set environment variable:export CMAKE_BUILD_TYPE=Release
CMake Tools Diagnostics
Debug Log
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: