How to fix CMake Parse error: Expected a command name, got unquoted argument with text "//"
Problem:
You want to build an application using CMake but you see an error message like this:
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 1
Solution
You CMakeLists.txt
likely looks like this:
// Create main executable
add_executable(main main.cpp)
The issue is in the first line:
// Create main executable
CMake comments start with #
, not with //
!
Change any comment line starting with //
to start with #
instead. In our example:
# Create main executable
add_executable(main main.cpp)
Then try building again (e.g. using cmake .
or make
). Unless you have other issues in your CMake configuration, the output should now look like this (for simple builds):
-- Configuring done
-- Generating done
-- Build files have been written to: /ram
[100%] Built target main