cmake-cpp
cmake-cpp copied to clipboard
Question on how the -DCMAKE_BUILD_TYPE:STRING=Debug is setup on running the project
Hello,
I am trying to understand CMake. I downloaded this repository and was able to run it on Linux via VSCode.
I noticed that one of the commands that gets run at start is:
[proc] Executing command: /snap/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ "-S/home/TryerGit/GoogleDrive/research_programming/Setup Folder/VSIDE,VSCodePractice/cmake/mizuk-cmake-cpp" "-B/home/TryerGit/GoogleDrive/research_programming/Setup Folder/VSIDE,VSCodePractice/cmake/mizuk-cmake-cpp/cmake/linux" -G Ninja
I understand that this is coming from the following part of CML file:
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(isMultiConfig)
if(NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING
"Choose the type of builds, options are: Debug Release RelWithDebInfo MinSizeRel. (default: Release;Debug)"
FORCE)
endif()
message(STATUS "Configuration types: ${CMAKE_CONFIGURATION_TYPES}")
else()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel. (default: Release)"
FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()
Could you please let me know where these various parameters are coming from? As soon as I open VSCode in this root directory, it recognizes this as a CML project and does these things automatically. In particular, where is CMAKE_BUILD_TYPE = Debug coming from?
Thank you.
What is a CML project ?
CMAKE_BUILD_TYPE is a builtin CMake parameter used by single configuration generator (like Ninja or Makefile).
Most IDE like to force Debug mode so it easier to debug/breakpoint etc...
ref: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html