问题分析 4
CMake-tools 不能正常工作【已解决】
[main] 正在配置项目: CppLearn
[proc] 执行命令: /usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -C /home/pomegranate/workspace/CppLearn -S/home/pomegranate/workspace/CppLearn -B/home/pomegranate/workspace/CppLearn/build
[cmake] Not searching for unused variables given on the command line.
[cmake] loading initial cache file /home/pomegranate/workspace/CppLearn
[cmake] CMake Error: Error processing file: /home/pomegranate/workspace/CppLearn
[cmake] -- SOURCES: /home/pomegranate/workspace/CppLearn/practice/chapter12/a.cpp;/home/pomegranate/workspace/CppLearn/practice/chapter12/main.cpp
[cmake] -- HEADERS: /home/pomegranate/workspace/CppLearn/practice/chapter12;thirdpaties/Plog/include
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/home/pomegranate/workspace/CppLearn/build/CMakeFiles/CMakeOutput.log".
[proc] 命令“/usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -C /home/pomegranate/workspace/CppLearn -S/home/pomegranate/workspace/CppLearn -B/home/pomegranate/workspace/CppLearn/build”已退出,代码为 1
问题猜想:/usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -C /home/pomegranate/workspace/CppLearn -S/home/pomegranate/workspace/CppLearn -B/home/pomegranate/workspace/CppLearn/build
命令有误【确凿】
验证:命令行运行该命令
Not searching for unused variables given on the command line.
loading initial cache file /home/pomegranate/workspace/CppLearn
CMake Error: Error processing file: /home/pomegranate/workspace/CppLearn
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- SOURCES: /home/pomegranate/workspace/CppLearn/practice/chapter12/a.cpp;/home/pomegranate/workspace/CppLearn/practice/chapter12/main.cpp
-- HEADERS: /home/pomegranate/workspace/CppLearn/practice/chapter12;thirdpaties/Plog/include
-- Configuring incomplete, errors occurred!
See also "/home/pomegranate/workspace/CppLearn/build/CMakeFiles/CMakeOutput.log".
问题猜想:-C XXX
选项有误【确凿】
验证:删除 -C 重新允许命令
Not searching for unused variables given on the command line.
-- SOURCES: /home/pomegranate/workspace/CppLearn/practice/chapter12/a.cpp;/home/pomegranate/workspace/CppLearn/practice/chapter12/main.cpp
-- HEADERS: /home/pomegranate/workspace/CppLearn/practice/chapter12;thirdpaties/Plog/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pomegranate/workspace/CppLearn/build
解决方法:配置 cmake-tools 插件的行为,排查全局 settings.json【有效】
"cmake.cacheInit": "" // 发现官方脚本 Bug
删除即可