/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


如您所见,我的命令将分号视为命令的结尾,然后尝试将“ -Werror”解释为新命令。如何告诉cmake生成有效的makefile而不是损坏的makefile?

这是我的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)

最佳答案

您只能将字符串/附加字符串添加到CMAKE_CXX_FLAGS,而不能添加列表。

以下应该工作:

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

关于c++ - cmake生成错误的makefile,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25275031/

10-09 13:30