0
/usr/bin/clang++ -std=c++11;-Werror;-Wextra;-Wall;-Wconversion -g -o CMakeFiles/TilingGame.dir/src/streak.cc.o -c /home/arne/projects/tilinggame/src/streak.cc clang: error: no input files /bin/sh: -Werror: Kommando nicht gefunden. /bin/sh: -Wextra: Kommando nicht gefunden. /bin/sh: -Wall: Kommando nicht gefunden. /bin/sh: -Wconversion: Kommando nicht gefunden. CMakeFiles/TilingGame.dir/build.make:54: recipe for target 'CMakeFiles/TilingGame.dir/src/streak.cc.o' failed 

as you can see my shees sees the semicolon as the end of the command and then tries to interpret "-Werror" as a new command. How can I tell cmake to generate working makefiles instead of broken ones?

here is my CMakeLists.txt

project(TilingGame) cmake_minimum_required(VERSION 2.8) aux_source_directory(src SRC_LIST) add_executable(${PROJECT_NAME} ${SRC_LIST}) set(CMAKE_CXX_FLAGS -std=c++11 -Werror -Wextra -Wall -Wconversion) include(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image) PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer) PKG_SEARCH_MODULE(SDL2TTF REQUIRED SDL2_ttf) PKG_SEARCH_MODULE(ZLIB REQUIRED zlib) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2MIXER_LIBRARIES} ${SDL2TTF_LIBRARIES} ${ZLIB_LIBRARIES} tmxparser tinyxml) 
3
  • Consider using target_compile_options instead of CMAKE_CXX_FLAGS. It offers better control over the scope of the flags and integrates more nicely with third-party CMake scripts. Commented Aug 13, 2014 at 7:28
  • @ComicSansMS I tried the command. The documentation has no example and all information I get when I use it is this: target compile options called with invalid arguments. So is there an example Commented Aug 13, 2014 at 15:00
  • A simple example would be target_compile_options(${PROJECT_NAME} PUBLIC -std=c++11 -Werror -Wextra -Wall -Wconversion). Note that this approach also works without the quotes. Commented Aug 13, 2014 at 15:18

2 Answers 2

2

Since you don't show us the section of your cmake file where you are adding those flags we can't say exactly. However, clearly somehow you're causing cmake to convert a list of values into a string and then using that string as flags. The string-ified version of list variables in cmake are semicolon-separated.

For example maybe you have something like this in your CMakeLists.txt:

set(FLAGS -std=c++11 -Werror -Wextra -Wall -Wconversion) add_definitions("${FLAGS}") 

You should not use the quotes here.

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

2 Comments

I added the CMakeLists.text now. Btw I also found a solution that at least works temporarily: I use quotes around all the flags.
Assuming you mean enclosing all the flags in one set of quotes, that's the right answer. The CMAKE_CXX_FLAGS variable is apparently expected to contain a string, not a list, and is quoted by cmake.
1

You can only add strings/append strings to CMAKE_CXX_FLAGS, but not lists.

The following should work:

set(CMAKE_CXX_FLAGS "-std=c++11 -Werror -Wextra -Wall -Wconversion") 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.