I'm doing a shool assignment which involves CMake.
I'm trying to import the CMake project in CLion but I get the following error:
CMake Error at CMakeLists.txt:35: Parse error. Expected a command name, got unquoted argument with text "add_subdirectory​".
The line specified is the following:
# Add terminal sub directory
add_subdirectory(terminal)
target_link_libraries(${Screen} Terminal)
The whole CMake file:
# Projektets namn
project(Screen)
# Minsta tillåtna cmake version
cmake_minimum_required(VERSION 3.2)
# Kompilera med c++ 11 stöd
set (CMAKE_CXX_STANDARD 11)
# Lägg till katalogen med våra bibliotek till INCLUDE path
# (i dessa kataloger kommer kompilatorn att leta efter de
# header filer som inkluderas i koden)
INCLUDE_DIRECTORIES($ENV{TOOLS_INCLUDE})
# Ta med alla källkodsfiler i den aktuella katalogen och
# lägger dem i listan SRC_LIST.
aux_source_directory(. SRC_LIST)
# Om Debug mode
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Skriv ut meddelandet Debug mode samt sätt kompilator
# direktivet DEBUG
message("Debug mode")
add_definitions(-DDEBUG)
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Skriv ut meddelandet Release mode.
message("Release mode")
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Skapa en exekverbar fil med källkodsfilerna i från
# SRC_LIST. Första parametern är namnet på målet (Target)
add_executable(${PROJECT_NAME} ${SRC_LIST})
# Add terminal sub directory
add_subdirectory(terminal)
target_link_libraries(${{PROJECT_NAME} Terminal)
Any ideas what I'm doing wrong here?
The command you used is:
add_subdirectory(terminal)
but the (
char is preceded and followed by a null char. This is invisible, but can be debugged using a hex editor, or any text editor that highlight this kind of error (I detected it using Sublime Text).
Simply replace this line by:
add_subdirectory(terminal)
Note: see the difference between 2 lines in HxD, a hexadecimal editor:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With