如何在Visual Studio 2022中禁用CMake脚本建议更改提示
关闭CMake新建文件时的Preview Changes弹窗
针对CLion用户
- 打开设置(快捷键Ctrl+Alt+S,或顶部菜单
File > Settings) - 依次展开
Build, Execution, Deployment > CMake - 在右侧「Automatic CMake project reloading」区域,取消勾选「Show preview window when changes are suggested」
- 也可以直接在设置搜索框输入「CMake Preview Changes」,找到对应选项关闭
如果想彻底关掉自动提示添加文件的功能:
- 打开设置后进入
Editor > General > Auto Import - 取消勾选CMake相关的「Add imported files to CMake targets automatically」选项
针对Visual Studio用户
- 顶部菜单点击
工具 > 选项(Tools > Options) - 展开
CMake > General - 取消勾选「Prompt for changes when files are added or removed from the project」
额外提示
如果你一直用file(GLOB_RECURSE)批量导入头文件,确保CMakeLists.txt写法规范,比如:
# 批量获取所有头文件 file(GLOB_RECURSE PROJECT_HEADERS "include/*.h") # 将头文件关联到目标 target_sources(YourProjectName PRIVATE ${PROJECT_HEADERS})
规范写法能减少IDE的不必要提示。
内容的提问来源于stack exchange,提问作者Lex
相关产品推荐
相关产品推荐

