移动目录后编辑和删除CMakeCache.txt [英] Editing versus deleting CMakeCache.txt after moving directory

查看:1258
本文介绍了移动目录后编辑和删除CMakeCache.txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在移动源目录后重新执行CMake,则会出现如下错误:

If CMake is re-executed after the source directory is moved, an error like this is given:


CMake错误:当前CMakeCache.txt目录/new-path/CMakeCache.txt与创建CMakeCache.txt的目录/ old-path不同。这可能会导致在错误的位置创建二进制文件。如果不确定,请重新编辑CMakeCache.txt

CMake Error: The current CMakeCache.txt directory /new-path/CMakeCache.txt is different than the directory /old-path 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

处理此问题的最佳方法是什么?似乎删除缓存有效。为什么我要编辑 CMakeCache.txt 而不是仅仅删除它?

What is the best approach to deal with this? It seems that deleting the cache works. Why might I want to edit CMakeCache.txt, rather than just delete it?

推荐答案

我认为您最好的选择确实是删除缓存并重新创建它。实际上,如果我需要移动源代码,我倾向于走得更远,并删除整个构建树,但这可能是多余的。

I think your best bet is indeed to delete the cache and re-create it. In fact, I tend to go further and remove the entire build tree if I need to move the source, but this is probably overkill.

CMakeCache.txt文件可以可以通过CMake GUI进行编辑,或者如果您确定自己在做什么,则可以手动进行编辑,但是与从头开始重新运行cmake相比,我发现通常不值得花很多精力。我猜想运行CMake是否会花费大量时间(例如,如果您使用 ExternalProject_Add (可能涉及下载和构建第三方资源),则最好修改CMakeCache.txt。

The CMakeCache.txt file can be edited via the CMake GUI or by hand if you're sure what you're doing, but I find it's not usually worth the effort compared to re-running cmake from scratch. I guess if running CMake takes a significant amount of time (e.g. if you use ExternalProject_Add which could involve downloading and building a third-party resource), it may be preferable to modify the CMakeCache.txt.

本文提供了有关CMakeCache的更多详细信息。 txt文件并进行编辑。特别是它说:

This article provides a bit more detail about the CMakeCache.txt file and editing it. In particular it says:


编辑缓存的主要原因是给CMake本地文件库(例如JPEG)的位置,或者阻止它从使用本机库并在源代码树中使用该库的版本。

The main reason for editing the cache would be to give CMake the location of a native library such as JPEG, or to stop it from using a native library and use a version of the library in your source tree.

CMake不会更改缓存文件本身中的现有条目。如果您的CMakeLists.txt文件发生了重大变化,则需要从缓存文件中删除相关条目。如果尚未手动编辑缓存文件,则可以在重新运行CMake之前将其删除。

CMake will not alter an existing entry in the cache file itself. If your CMakeLists.txt files change significantly, you will need to remove the relevant entries from the cache file. If you have not already hand-edited the cache file, you could just delete it before re-running CMake.

这篇关于移动目录后编辑和删除CMakeCache.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆