If you want arbitrary customization, no. Not through the CMake: Quick Start
command / mechanism.
At least at the time of this writing, it's hardcoded. You can see for yourself in https://github.com/microsoft/vscode-cmake-tools/blob/15ad70769f62b5ce902b6fd1ae27986bb958d3d0/src/cmakeProject.ts#L2903.
You can make something custom through custom user snippets, but it'll be nowhere near as nice of a workflow as CMake: Quick Start
.
Ex. this file template snippet, while you could put in a cmake.json file (run Snippets: Configure User Snippets
and select "cmake", assuming you have a language support extension for CMake that contributes a language with that ID):
{
"Project CMakeLists.txt": {
"prefix": "CMake Project CMakeLists.txt",
"isFileTemplate": true,
"description": "For filling a new project's top-level CMakeLists.txt file",
"body": "cmake_minimum_required(VERSION ${1:3.29})\nproject(${2:${WORKSPACE_NAME}}\n\tVERSION ${3:0.0.1}\n\tDESCRIPTION [[${4}]]\n\tHOMEPAGE_URL [[${5}]]\n\tLANGUAGES ${6:CXX}\n)\nadd_${7|executable,library|}(${8:${2}}\n\t${9/([^\\n]+\\.c[px]?[px]?\\n)|([^\\n]+\\n)/\t$1/mgsu}\n)\ntarget_compile_features(${8} PUBLIC ${10:cxx_std_20})\n${LINE_COMMENT} set_target_properties(${8} PROPERTIES )\ntarget_include_directories(${8} PUBLIC ${11:include})\n${LINE_COMMENT} ${12|enable_testing(),include(CTest)|}",
},
}
It's a little gnarly since I insisted upon not requiring any utility extensions.
For the section for populating source files, you can use this keybinding to copy relative paths for all files from the Explorer View, then paste them into there:
{
"key": "ctrl+b", // TODO
"command": "runCommands",
"args": { "commands": [
"workbench.files.action.focusFilesExplorer",
"list.closeFind",
"list.selectAll",
"copyRelativeFilePath",
"list.clear",
"workbench.action.focusActiveEditorGroup"
]},
"when": "editorLangId == cmake && inSnippetMode && editorFocus",
},
And then when you tab out of that snippet placeholder, the snippet logic will remove any files that don't have certain filename extensions.
For the specific code you showed you want in the question post, note that you probably instead want to use CMAKE_<LANG>_FLAGS_<CONFIG>
, and note that CMAKE_<LANG>_FLAGS
typically affects the link command as well by default (see the first line of the docs). And for this stuff, it's probably more appropriate to specify in cmake.configureSettings
, or a preset file, or a file specified by CMAKE_PROJECT_TOP_LEVEL_INCLUDES
.
file(DOWNLOAD)
and theninclude()
, orFetchContent
. – Radu