c++ - CMake 引用我在 ~/bin 中创建的随机 shell 脚本(即使在我删除它之后)?
问题描述
在 Ubuntu(20.04,Cinnamon 桌面)中,我创建了一个基本的 shell 脚本来从命令行运行具有以下内容的 .desktop 文件:
#!/bin/sh
$(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
然后运行chmod +x
以便能够将其作为命令执行。现在,每当我使用 时cmake --build
,它都会包含这个文件的内容——即使在我删除了有问题的脚本并完全重新启动之后。这是我最近尝试 cmake 的输出:
alexander@alexander-Inspiron-7559:~/Documents/Code/CPP/SDLProject/bin$ cmake --build .
CMake Error: The current CMakeCache.txt directory /home/alexander/Documents/Code/CPP/SDLProject/bin/CMakeCache.txt is different than the directory /home/alexander/Documents/Code/CPP/OGRE-Project-1/bin where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
[ 0%] Building CXX object CMakeFiles/SDLProject.dir/src/main.cpp.o
In file included from /home/alexander/Documents/Code/CPP/OGRE-Project-1/src/App.hpp:10,
from /home/alexander/Documents/Code/CPP/OGRE-Project-1/src/main.cpp:1:
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/text/Label.hpp:8:8: warning: character constant too long for its type
8 | $(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
| ^~~~~~~
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/text/Label.hpp:8:35: warning: character constant too long for its type
8 | $(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
| ^~~~~~~~~~~~
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/text/Label.hpp:8:54: warning: character constant too long for its type
8 | $(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
| ^~~~~~~~
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/text/Label.hpp:8:69: warning: character constant too long for its type
8 | $(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
| ^~~~~~~~~
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/text/Label.hpp:8:85: warning: character constant too long for its type
8 | $(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
| ^~~~~~~~~~~
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/text/Label.hpp:8:2: error: expected constructor, destructor, or type conversion before ‘(’ token
8 | $(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g') &
| ^
In file included from /home/alexander/Documents/Code/CPP/OGRE-Project-1/src/main.cpp:1:
/home/alexander/Documents/Code/CPP/OGRE-Project-1/src/App.hpp:24:2: error: ‘Label’ does not name a type
24 | Label *lb;
| ^~~~~
make[2]: *** [CMakeFiles/SDLProject.dir/build.make:63: CMakeFiles/SDLProject.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/SDLProject.dir/all] Error 2
make: *** [Makefile:84: all] Error 2```
解决方案
查看您创建然后删除的脚本是否在 CMakeCache.txt 文件中被引用。如果是,则删除/删除引用。
我记得 Cmake 是一个“源目录外”构建工具(您创建一个新的空构建目录,然后引用您的源目录)。当它开始构建时,它会为文件生成一个缓存/列表——参见“CMakeCache.txt”——以在编译时帮助解决依赖关系。
删除“CMakeCache.txt”文件也可能对您有用,因为它将由 cmake 重新生成。
推荐阅读
- r - 如何读取未知编码(FDF)的文件
- node.js - 如何在打字稿中获得与 Express 的 Post 方法相同的数据类型
- angular - 如何解决 Angular 中的 HTTPErrosResponse 问题
- android - 从其他 PC 编译时,Google Fit 应用程序无法正常工作
- sql - 如何在 Oracle 查询中从 XML 字段中选择值
- c++ - boost加月的行为原理是什么?
- selenium - Selenium 和非无头浏览器不断要求验证码
- asp.net-web-api - 哪个请求文化提供者是更好的选择
- android - 如何在 Material Bottom App Bar 中自定义视图?
- ios - 如何在 UIView 顶部设置阴影?