In this post, 2 CMake topics:
- when using VSCode, how do you build a debug or release binary
- how to set the c/c++ standard (e.g.: the new c++20 standard)?
Build a CMake Debug or Release binary in VSCode
CMake can generate debug or release binaries easily. On a command line, you'd indicate that by calling:
cmake -DCMAKE_BUILD_TYPE=Debug|Release
In VSCode, you do this in the status bar:
When you click on that section, you get a pop-up for all registered build configurations:
Select the release you want to build. That's all.
Set the c or c++ standard
The c and c++ languages evolve. Toolchains support backward compatibility, by allowing you to say you're using an old standard. CMake supports that too. Here's a CMakeList.txt example that indicates that you're using c11 and c++20:
cmake_minimum_required(VERSION 3.13)
# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)
project(spi_flash C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
pico_sdk_init()