microsoft / microsoft/vscode-cmake-tools
CMake Tools does not detect when CMAKE_TOOLCHAIN_FILE is set within a CMakeLists.txt
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
I am attempting to develop against the [raspberry pi pico](https://github.com/raspberrypi/pico-sdk) SDK in conjunction with [CPM](https://github.com/cpm-cmake/CPM.cmake) within vscode. This SDK comes with toolchains files and sets the CMAKE_TOOLCHAIN_FILE variable during part of its bootup. My simplified CMakeLists.txt looks like:
```CMake
cmake_minimum_required(VERSION 3.25)
project(MyProject C CXX ASM)
# set up CPM - you may have to create the below directory
set(CPM_SOURCE_CACHE "/tmp/.cache")
include(cmake/get_cpm.cmake)
# download the sdk
CPMAddPackage(
NAME pico-sdk
GITHUB_REPOSITORY raspberrypi/pico-sdk
GIT_TAG 1.5.1
DOWNLOAD_ONLY TRUE
)
# download the sdk extras
CPMAddPackage(
NAME pico-extras
GITHUB_REPOSITORY raspberrypi/pico-extras
GIT_TAG sdk-1.5.1
DOWNLOAD_ONLY TRUE
)
# sdk configuration variables
set(PICO_BOARD pico_w CACHE STRING "" FORCE)
set(PICO_SDK_PATH ${CPM_PACKAGE_pico-sdk_SOURCE_DIR} CACHE PATH "")
set(PICO_EXTRAS_PATH ${CPM_PACKAGE_pico-extras_SOURCE_DIR} CACHE PATH "")
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include(${PICO_EXTRAS_PATH}/external/pico_extras_import.cmake)
# Initialize the SDK
pico_sdk_init()
add_subdirectory(my_code)
```
This configures just fine, but I am unable to compile as it has selected the wrong toolchain. I also cannot manually select the arm compilers, as I get "cannot compile a simple test program".
I have resorted for the moment in adding the following code to my root file:
```CMake
file(WRITE "${CMAKE_CURRENT_LIST_DIR}/.vscode/cmake-kits.json"
"[
{
\"name\": \"PICO\",
\"toolchainFile\": \"${PICO_SDK_PATH}/cmake/preload/toolchains/pico_arm_gcc.cmake\"
}
]"
)
```
However, this is not ideal. I would expect the cmake tools extension to detect when CMAKE_TOOLCHAINS_FILE is set and react accordingly.
Thank you guys for an awesome extension!!
### CMake Tools Diagnostics
_No response_
### Debug Log
_No response_
### Additional Information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Raspberry Pi Pico setup from the issue's CMakeLists.txt and compare it with the generated .vscode/cmake-kits.json workaround. Read the CMake Tools configuration and toolchain-selection entry points; done means a CMAKE_TOOLCHAIN_FILE set during CMake configuration is detected and the corresponding toolchain is selected without generating a kit manually.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100