Editing versus deleting CMakeCache.txt after moving directory

前端 未结 2 1253
星月不相逢
星月不相逢 2021-01-01 17:24

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

CMake Error: The current CMakeCache.txt directory /new-path/

相关标签:
2条回答
  • 2021-01-01 17:31

    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.

    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.

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

    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 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.

    0 讨论(0)
  • 2021-01-01 17:56

    I ran into same error while running a CGAL code (which I had already compiled sometime ago) . All I did was create a new directory and copy the ".cpp" file there and run " CGAL_create_CMakelists " and then run cmake command.It worked this way. I don't exactly know but I think the error comes when you run the code which was already compiled and has its build files already in the folder(due to previous compiling).

    0 讨论(0)
提交回复
热议问题