microsoft / microsoft/vscode-cmake-tools
Failed to configure a cmake project under drive root
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
#### CMakeLists.txt
```cmake
cmake_minimum_required(VERSION 3.30)
project(tmp)
file(TOUCH tmp.cpp)
add_library(tmp tmp.cpp)
```
Put the `CMakeLists.txt` under drive root, e.g. `D:`, (or any folder and then `subst`), then open drive root with vscode.
### CMake Tools Diagnostics
```shell
{
"os": "win32",
"vscodeVersion": "1.92.1",
"cmtVersion": "1.18.44",
"configurations": [
{
"folder": "d:\\",
"cmakeVersion": "3.30.2",
"configured": true,
"generator": "Ninja",
"usesPresets": false,
"compilers": {
"C": "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe",
"CXX": "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [
"file:///d%3A/hello.cpp"
],
"responses": [],
"partialMatches": [],
"targetCount": 1,
"executablesCount": 1,
"librariesCount": 0,
"targets": [
{
"name": "tmp",
"type": "EXECUTABLE"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
}
]
}
```
### Debug Log
```shell
[proc] : "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -SD:. -Bd:/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is MSVC 19.40.33813.0
[cmake] -- The CXX compiler identification is MSVC 19.40.33813.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - 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: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Configuring done (1.3s)
[cmake] CMake Error at CMakeLists.txt:4 (add_library):
[cmake] Cannot find source file:
[cmake]
[cmake] tmp.cpp
[cmake]
[cmake]
[cmake] CMake Error at CMakeLists.txt:4 (add_library):
[cmake] No SOURCES given to target: tmp
[cmake]
[cmake]
[cmake] CMake Generate step failed. Build files cannot be regenerated correctly.
```
### Additional Information
I suspect the option `-SD:.` passed to cmake is the cause.
Contributor guide
Research direction
Start with the CMakeLists.txt reproduction and the logged configure command, especially the -SD:. source path when the project is opened at a Windows drive root. Reproduce the failure with CMake Tools 1.18.44, then compare configuration from a normal folder and a drive root. Done means the root-based project configures without the reported missing tmp.cpp error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100