microsoft / microsoft/vscode-cmake-tools
Configuring with an existing build directory doesn't work properly
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
When configuring a project (e.g. adding a new CMake target or simply reloading VS Code), CMake will often complain that it can't find certain paths, which are empty. If the build directory is deleted, VS Code restarted, and the project is configured from scratch, then this isn't an issue.
### Expected:
`CMake: Configure Project` works regardless of whether or not there's a cache.
### Apparent Behavior:
My brief looking into this has determined that configuring seems to not pass in variables that the are being expected by CMake. This wasn't an issue ~a month ago.
### CMake Tools Log
#### Logs without pre-xisting cache
```
[main] Configuring folder: lectures
[cmake] -- Looking for C++ include pthread.h - found
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
[cmake] -- Looking for pthread_create in pthreads
[cmake] -- Looking for pthread_create in pthreads - not found
[cmake] -- Looking for pthread_create in pthread
[cmake] -- Looking for pthread_create in pthread - found
[cmake] CMake Warning (dev) at /home/cjdb/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
[cmake] The package name passed to `find_package_handle_standard_args` (Threads)
[cmake] does not match the name of the calling package (absl). This can lead to
[cmake] problems in calling code that expects `find_package` result variables
[cmake] (e.g., `_FOUND`) to follow a certain pattern.
[cmake] Call Stack (most recent call first):
[cmake] /home/cjdb/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.17/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
[cmake] vcpkg/installed/x64-linux-libcxx/share/absl/abslConfig.cmake:3 (include)
[cmake] vcpkg/scripts/buildsystems/vcpkg.cmake:439 (_find_package)
[cmake] CMakeLists.txt:29 (find_package)
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- Found Threads: TRUE
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/cjdb/projects/cs6771/lectures/build
```
#### Logs with pre-existing cache
```
[main] Configuring folder: lectures
[proc] Executing command: /home/cjdb/.local/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_TOOLCHAIN_FILE:FILEPATH=/home/cjdb/projects/cs6771/lectures/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE:STRING=/home/cjdb/projects/cs6771/lectures/config/cmake/toolchains/clang-libcxx.cmake -DVCPKG_TARGET_TRIPLET:STRING=x64-linux-libcxx -DCMAKE_C_COMPILER:STRING=/usr/bin/clang-11 -DCMAKE_CXX_COMPILER:STRING=/usr/bin/clang++-11 -DCMAKE_PREFIX_PATH:STRING=/usr/lib/llvm-11 -H/home/cjdb/projects/cs6771/lectures -B/home/cjdb/projects/cs6771/lectures/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Found /usr/bin/clang-tidy-11
[cmake] CMake Warning (dev) at /home/cjdb/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
[cmake] The package name passed to `find_package_handle_standard_args` (Threads)
[cmake] does not match the name of the calling package (absl). This can lead to
[cmake] problems in calling code that expects `find_package` result variables
[cmake] (e.g., `_FOUND`) to follow a certain pattern.
[cmake] Call Stack (most recent call first):
[cmake] /home/cjdb/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.17/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
[cmake] vcpkg/installed/x64-linux-libcxx/share/absl/abslConfig.cmake:3 (include)
[cmake] vcpkg/scripts/buildsystems/vcpkg.cmake:439 (_find_package)
[cmake] CMakeLists.txt:29 (find_package)
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- Configuring done
[cmake] You have changed variables that require your cache to be deleted.
[cmake] Configure will be re-run and you may have to reset some variables.
[cmake] The following variables have changed:
[cmake] CMAKE_CXX_COMPILER= /usr/bin/clang++-11
[cmake]
[cmake] -- The CXX compiler identification is Clang 11.0.0
[cmake] -- Check for working CXX compiler: /usr/bin/clang++-11
[cmake] -- Check for working CXX compiler: /usr/bin/clang++-11 - works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- CJDB_CLANG_TIDY_PATH="" not found.
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/home/cjdb/projects/cs6771/lectures/build/CMakeFiles/CMakeOutput.log".
[cmake] CMake Error at /home/cjdb/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
[cmake] Could NOT find ClangTidy (missing: ClangTidy_FOUND)
[cmake] Call Stack (most recent call first):
[cmake] /home/cjdb/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
[cmake] config/cmake/FindClangTidy.cmake:26 (find_package_handle_standard_args)
[cmake] CMakeLists.txt:24 (find_package)
[cmake]
[cmake]
```
### Developer Tools Log
Not sure how to retrieve
### Platform and Versions
- **Operating System**: Windows 10 2004 + WSL2, but this is also problematic on Debian
- **CMake Version**: 3.17.3, but I believe this to be an issue as far back as 3.13
- **VSCode Version**: 1.47.0
- **CMake Tools Extension Version**: v1.4.1
- **Compiler/Toolchain**: LLVM 11
### vscode/.cmake-kits.json
```
{
"name": "Home PC",
"toolchainFile": "${workspaceFolder}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"preferredGenerator": {
"name": "Ninja"
},
"cmakeSettings": {
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${workspaceFolder}/config/cmake/toolchains/clang-libcxx.cmake",
"VCPKG_TARGET_TRIPLET": "x64-linux-libcxx",
"CMAKE_C_COMPILER": "/usr/bin/clang-11",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-11",
"CMAKE_PREFIX_PATH": "/usr/lib/llvm-11"
}
}
```
Contributor guide
Research direction
Reproduce the issue with the CMake: Configure Project entry point, comparing the clean-cache and existing-cache logs. Inspect vscode/.cmake-kits.json, CMakeLists.txt, and config/cmake/FindClangTidy.cmake while tracing how kit variables become the configure command. Done means reconfiguring an existing build directory succeeds without empty paths or missing ClangTidy variables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript, vscode
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100