Wie man 'CMake generation is not allowed within the source directory' behebt
Problem
Beim Bauen eines CMake-Projekts sehen Sie eine Fehlermeldung wie
cmake_run_in_build_dir.txt
CMake Error at CMakeLists.txt:844 (message):
CMake generation is not allowed within the source directory! Remove the
CMakeCache.txt file and try again from another folder, e.g.: rm
CMakeCache.txt mkdir cmake-make cd cmake-make cmake ..Lösung
Dieses Projekt verlangt, dass Sie ein separates Build-Verzeichnis erstellen und CMake von dort ausführen. So können Sie das machen:
Erstellen Sie ein neues Verzeichnis für die Build-Dateien:
mkdir_build.shmkdir build cd buildFühren Sie CMake aus dem neuen Verzeichnis aus:
cmake_build.sh
cmake ..Beachten Sie, dass es cmake .. ist, nicht cmake ., da Sie möchten, dass CMake das Projekt aus dem übergeordneten Verzeichnis baut.
Wenn das nicht funktioniert hat, müssen Sie die CMakeCache.txt-Datei entfernen und es erneut versuchen:
remove_cmakecache.sh
rm CMakeCache.txt # if you are running from the root of the project
rm ../CMakeCache.txt # if you are running this from the build directoryVersuchen Sie dann, cmake .. erneut auszuführen.
Check out similar posts by category:
Build Systems
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow