From 010d72049c046250a1c35cb8e92d6a0ea8d2bdef Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Fri, 9 Aug 2024 23:23:09 +0200 Subject: [PATCH] Use `set_source_files_properties` for warning flags in CMake. Fixes #3029 --- CMakeLists.txt | 2 +- mk/cmake/SuperTux/WarningFlags.cmake | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8133c22ac5b..0733a823320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,7 +236,7 @@ endif() target_link_libraries(supertux2 supertux2_lib) set_target_properties(supertux2_lib PROPERTIES OUTPUT_NAME supertux2_lib) -set_target_properties(supertux2_lib PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}") +set_source_files_properties(${SUPERTUX_SOURCES_CXX} PROPERTIES COMPILE_OPTIONS "${SUPERTUX2_EXTRA_WARNING_FLAGS}") if(EMSCRIPTEN) target_link_options(supertux2 PUBLIC -sEXPORTED_FUNCTIONS=['_main','_set_resolution','_save_config','_onDownloadProgress','_onDownloadFinished','_onDownloadError','_onDownloadAborted','_getExceptionMessage'] PUBLIC -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap']) endif() diff --git a/mk/cmake/SuperTux/WarningFlags.cmake b/mk/cmake/SuperTux/WarningFlags.cmake index 1df05966564..36847e160c3 100644 --- a/mk/cmake/SuperTux/WarningFlags.cmake +++ b/mk/cmake/SuperTux/WarningFlags.cmake @@ -9,7 +9,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_LD_FLAGS_PROFILE "-lgmon" CACHE STRING "Profile flags") if(WERROR) - string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS "-Werror ") + string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS "-Werror;") endif() if(WARNINGS) @@ -75,7 +75,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") foreach(flag IN LISTS ALL_WARNING_FLAGS) check_cxx_compiler_flag(${flag} HAVE_FLAG_${flag}) if(HAVE_FLAG_${flag}) - string(APPEND SUPERTUX2_EXTRA_WARNING_FLAGS "${flag} ") + string(APPEND SUPERTUX2_EXTRA_WARNING_FLAGS "${flag};") endif() unset(HAVE_FLAG CACHE) endforeach(flag IN LISTS ALL_WARNING_FLAGS) @@ -87,9 +87,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") check_cxx_compiler_flag(-Wpoison-system-directories HAVE_POISON_SYSTEM_DIRECTORIES_WARNING) endif() if(HAVE_POISON_SYSTEM_DIRECTORIES_WARNING) - string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS - "${SUPERTUX2_EXTRA_WARNING_FLAGS} " - "-Wno-poison-system-directories ") + string(APPEND SUPERTUX2_EXTRA_WARNING_FLAGS "-Wno-poison-system-directories;") endif() endif() endif()