7

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?

2
  • Please provide lines preceding your "add_subdirectory()" command. I suspect a missing closing parenthesis in previous command. BTH, your use of "add_subdirectory()" seems valid Commented Oct 6, 2017 at 13:24
  • @Antwane Updated the post. Commented Oct 6, 2017 at 13:25

1 Answer 1

12
+50

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:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

mmm I have the same problem but with an hexadecimal editor I see nothing of this sort
This must've been a particular case

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.