Open huangqinjin opened 2 months ago
The issue you're encountering with CMake appears to be related to the file(TOUCH tmp.cpp)
command in your CMakeLists.txt
. The file(TOUCH tmp.cpp)
command creates an empty file tmp.cpp
but doesn't ensure it is correctly handled by CMake, especially if the file isn't present at the time of configuration. Here are steps to resolve the problem:
Create the Source File Manually: Ensure that tmp.cpp
exists in the directory where CMake expects it. You can manually create tmp.cpp
with some placeholder content, such as:
// tmp.cpp
int main() {
return 0;
}
Modify CMakeLists.txt
: To make your CMakeLists.txt
more robust, you might want to specify tmp.cpp
directly in the file
command or use file(WRITE ...)
to ensure the file content is initialized properly. For example:
cmake_minimum_required(VERSION 3.30)
project(tmp)
# Ensure tmp.cpp exists with some content
file(WRITE ${CMAKE_BINARY_DIR}/tmp.cpp "int main() { return 0; }")
# Add the library
add_library(tmp ${CMAKE_BINARY_DIR}/tmp.cpp)
Note that ${CMAKE_BINARY_DIR}
is used to ensure the file is created in the build directory.
Verify Paths: Ensure that paths are correctly specified. The error might also be due to an issue with where CMake is looking for tmp.cpp
. Ensure that tmp.cpp
is present in the expected location relative to the CMakeLists.txt
.
Re-run CMake: After making these changes, delete the existing build directory or any existing configuration files, and then re-run CMake:
cmake -DCMAKE_BUILD_TYPE=Debug -G Ninja ..
Check CMake Presets: If you're using CMake presets, ensure that the preset configuration matches the setup you intend to use. For instance, if using presets, you might need to adjust settings or paths in your CMakePresets.json file.
By ensuring tmp.cpp
is present and correctly referenced in CMakeLists.txt
, you should be able to resolve the issues you're facing.
The issue you're encountering with CMake appears to be related to the
file(TOUCH tmp.cpp)
command in yourCMakeLists.txt
.
No. It is just to make the repro minimal.
Reported upstream https://gitlab.kitware.com/cmake/cmake/-/issues/26222.
@huangqinjin, thanks for reporting this issue. Today we verified this issue with the CMakeLists.txt you mentioned, but we didn't repro it. Please see the below video. For further investigation, could you please share us a demo video with clear repro steps? We are looking forward to hearing from you. Thanks. ENV: VS Code:1.92.2 CMake Tools: v1.18.44 CMake: 3.30
@Evelyn-001 you are configuring the project from command line, nothing related to cmake-tools, please check the upstream issue.
To reproduce my issue reported here (cmake-tools), please simply click the Build button at the bottom status bar.
@huangqinjin, Thanks for your reply. We have reproduced this issue with below ENV. Our development team will investigate this issue later and we will provide you with any updates. Thank you for your support. Env: VS code: 1.92.2 CMake Tool: v1.18.44
Brief Issue Summary
CMakeLists.txt
Put the
CMakeLists.txt
under drive root, e.g.D:
, (or any folder and thensubst
), then open drive root with vscode.CMake Tools Diagnostics
Debug Log
Additional Information
I suspect the option
-SD:.
passed to cmake is the cause.