Behebung von CMake Parse error: Expected a command name, got unquoted argument with text "//"
English
Deutsch
Problem:
Du möchtest eine Anwendung mit CMake erstellen, aber du siehst eine Fehlermeldung wie diese:
cmake_parse_error_output.txt
CMake Error at CMakeLists.txt:1:
Parse error. Expected a command name, got unquoted argument with text
"//".
-- Configuring incomplete, errors occurred!
See also "/ram/CMakeFiles/CMakeOutput.log".
Makefile:176: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1Lösung
Deine CMakeLists.txt sieht wahrscheinlich so aus:
cmake_example.cmake
// Create main executable
add_executable(main main.cpp)Das Problem liegt in der ersten Zeile:
comment_with_slashes.cpp
// Create main executable
CMake-Kommentare beginnen mit #, nicht mit // !
Ändere jede Kommentarzeile, die mit // beginnt, so, dass sie stattdessen mit # beginnt. In unserem Beispiel:
CMakeLists_example.cmake
# Create main executable
add_executable(main main.cpp)Versuche dann erneut zu bauen (z.B. mit cmake . oder make). Sofern du keine anderen Probleme in deiner CMake-Konfiguration hast, sollte die Ausgabe nun so aussehen (für einfache Builds):
cmake_success_output.txt
-- Configuring done
-- Generating done
-- Build files have been written to: /ram
[100%] Built target mainCheck out similar posts by category:
CMake
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow