microsoft / microsoft/vscode-cmake-tools

Kits: Project Status settings override .vscode/settings.json settings

Open
#3,556 2 comments 1 reaction 1 assignee Claimed by @andreeis View on GitHub
bug Feature: configure
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

My `.vscode/settings.json` contains `"cmake.configureArgs"` including `"-DCMAKE_BUILD_TYPE=Release"`. When I call "CMake: Delete Cache and Reconfigure" the build uses `CMAKE_BUILD_TYPE=Debug` as observed in both `build/CMakeCache.txt` and in the build products. Lately I've been working around it by manually editing `build/CMakeCache.txt`, after which it builds correctly using the Release type, and this warning is logged:

> [cpptools] The build configurations generated do not contain the active build configuration. Using "Release" for CMAKE_BUILD_TYPE instead of "Debug" to ensure that IntelliSense configurations can be found

This issue only appeared very recently, maybe (guessing) v.1.16. This setup has been working for me for months prior.

This looks like closed issue #2353 which was fixed by PR #3267 and included in v1.15. However, I'm using CMake Tools v1.16.32 with VS Code 1.85.2 on macOS 14.3 on arm64.

It also resembles currently open #3507, but my problem isn't with keyboard shortcuts and menus.

The CMake: Log Diagnostics output includes the following where "buildTypesSeen" starts as "Debug" when I Delete Cache and Reconfigure, then changes to "Release" after I edit CMakeCache.txt and build again:

```
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Release"
],
```

There's no cpptools warning on the first build. It only appears after I edit the cache.

Particularly notable from the debug log is:

```
[cmakefileapi-driver] Invoking CMake with arguments [
...
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_BUILD_TYPE:STRING=Debug",
...
]
[proc] Executing command: cmake ... -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE:STRING=Debug ...
```

I don't know where the `CMAKE_BUILD_TYPE:STRING=Debug` comes from.

Thoughts?

### CMake Tools Diagnostics

```shell
{
"os": "darwin",
"vscodeVersion": "1.85.2",
"cmtVersion": "1.16.32",
"configurations": [
{
"folder": "/redacted",
"cmakeVersion": "3.20.6",
"configured": true,
"generator": "Ninja",
"usesPresets": false,
"compilers": {
"C": "/redacted/bin/arm-none-eabi-gcc",
"CXX": "/redacted/bin/arm-none-eabi-g++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Release"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 14,
"executablesCount": 1,
"librariesCount": 1,
"targets": [
{
"name": "cppcheck",
"type": "UTILITY"
},
{
"name": "debug",
"type": "UTILITY"
},
{
"name": "debug_rtos",
"type": "UTILITY"
},
{
"name": "debug_tui",
"type": "UTILITY"
},
{
"name": "dfu_flash",
"type": "UTILITY"
},
{
"name": "eng-release",
"type": "UTILITY"
},
{
"name": "flash",
"type": "UTILITY"
},
{
"name": "flash_sd",
"type": "UTILITY"
},
{
"name": "flash_secondary",
"type": "UTILITY"
},
{
"name": "linkerscript",
"type": "UTILITY"
},
{
"name": "memfault_upload",
"type": "UTILITY"
},
{
"name": "redacted.elf",
"type": "EXECUTABLE"
},
{
"name": "test",
"type": "UTILITY"
},
{
"name": "redacted",
"type": "STATIC_LIBRARY"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
```

### Debug Log

```shell
[main] Configuring project: redacted
[main] Saving open files before configure/build
[driver] Removing /redacted/build/CMakeCache.txt
[driver] Removing /redacted/build/CMakeFiles
[driver] Start configure
[driver] Running pre-configure checks and steps
[driver] Using compilers in GCC 10.3.1 arm-none-eabi for configure
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake /redacted/bin/cmake with arguments ["--no-warn-unused-cli","-DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi-gcc.cmake","-DCMAKE_BUILD_TYPE=Release","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-DCMAKE_C_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-gcc","-DCMAKE_CXX_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-g++","-S/redacted","-B/redacted/build","-G","Ninja"]
[proc] Executing command: /redacted/bin/cmake --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi-gcc.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-g++ -S/redacted -B/redacted/build -G Ninja
[proc] with environment: {"COMMAND_MODE":"unix2003","CONDA_DEFAULT_ENV":"redacted","CONDA_EXE":"/redacted/bin/conda","CONDA_PREFIX":"/redacted","CONDA_PREFIX_1":"/redacted","CONDA_PROMPT_MODIFIER":"(redacted) ","CONDA_PYTHON_EXE":"/redacted/bin/python","CONDA_SHLVL":"2","ELECTRON_NO_ATTACH_CONSOLE":"1","GPG_TTY":"$(tty)","GTEST_COLOR":"1","HOME":"/redacted","HOMEBREW_CELLAR":"/opt/homebrew/Cellar","HOMEBREW_PREFIX":"/opt/homebrew","HOMEBREW_REPOSITORY":"/opt/homebrew","INFOPATH":"/opt/homebrew/share/info:","LANG":"en_US.UTF-8","LOGNAME":"redacted","MANPATH":"/opt/homebrew/share/man::","MallocNanoZone":"0","OPENSSL_ROOT_DIR":"/opt/homebrew/opt/openssl@3","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","PATH":"/opt/homebrew/opt/postgresql@15/bin:/redacted/bin:/redacted/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin","PWD":"/redacted","SHELL":"/bin/zsh","SHLVL":"2","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.voHJSG0YGj/Listeners","STM32CubeMX_PATH":"/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources","TERM":"xterm-256color","TERM_PROGRAM":"Apple_Terminal","TERM_PROGRAM_VERSION":"453","TERM_SESSION_ID":"30C5028E-27EA-4DBA-B00F-BC2F1250F463","TMPDIR":"/var/folders/fh/2fwm8cqd4ld1zrlj5djsympr0000gn/T/","USER":"redacted","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CLI":"1","VSCODE_CODE_CACHE_PATH":"/Users/redacted/Library/Application Support/Code/CachedData/8b3775030ed1a69b13e4f4c628c612102e30a681","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/redacted","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/Users/redacted/Library/Application Support/Code/1.85-main.sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"53193","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.16363725.16363731.B1674C2E-2C58-4F5D-91C0-75EB8423D67A","__CFBundleIdentifier":"com.microsoft.VSCode","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","ELECTRON_RUN_AS_NODE":"1","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 10.3.1
[cmake] -- The CXX compiler identification is GNU 10.3.1
[cmake] -- The ASM compiler identification is GNU
[cmake] -- Found assembler: /redacted/bin/arm-none-eabi-gcc
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /redacted/bin/arm-none-eabi-gcc - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /redacted/bin/arm-none-eabi-g++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Cross Compiling - Building Firmware
[cmake] -- Using BOOTLOADER configuration
[cmake] -- Performing Test _Map1
[cmake] -- Performing Test _Map1 - Success
[cmake] -- Using unsigned MCUBoot images.
[cmake] -- Using unencrypted MCUBoot images.
[cmake] -- Saving to /redacted/build/src/version.c
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /redacted/build
[cmakefileapi-parser] Read reply folder: /redacted/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-5677fb66618395b36f79.json","cmakeFiles-v1-ebd02cb9496abc1d6315.json","codemodel-v2-8a532ff8c9e9fa97e379.json","index-2024-01-31T18-47-43-0202.json","target-redacted-Debug-7dc5e361a1e7fdd3be09.json","target-cppcheck-Debug-0905a2efaa8f218a3f36.json","target-debug-Debug-7663404d47e95df4a81d.json","target-debug_rtos-Debug-19bc255a0e57fb26773d.json","target-debug_tui-Debug-f1e90ccd576b6ff9962a.json","target-dfu_flash-Debug-4dba3b89c2c36be363e0.json","target-eng-release-Debug-531276c8ae821654621d.json","target-flash-Debug-0ead6b1d71a1d6310d13.json","target-flash_sd-Debug-780339de46484680e4c0.json","target-flash_secondary-Debug-dc6aa8519f779e2d2b71.json","target-linkerscript-Debug-32b733ac427d6714ff4e.json","target-memfault_upload-Debug-91407e6e389bd9c7ce16.json","target-redacted-dbg.elf-Debug-a577e3babbe62209654b.json","target-test-Debug-4a067fcb87334d7d1d62.json","toolchains-v1-176adda914df9887b2c1.json"]
[cache] Reading CMake cache file /redacted/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [8081] cmake.cleanConfigure finished (returned 0)
```

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.