Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify WarningFlags.cmake by checking if compiler supports warning flag #3042

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion external/simplesquirrel
Submodule simplesquirrel updated 1 files
+2 −2 CMakeLists.txt
142 changes: 67 additions & 75 deletions mk/cmake/SuperTux/WarningFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,85 +19,77 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# -Wpadded -Wabi -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5
# fails on MinGW:
# -ansi
if(CMAKE_COMPILER_IS_GNUCXX)
string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
"-Wall "
"-Wextra "
"-fdiagnostics-show-option "
"-pedantic "
"-Wno-long-long "
"-Wcast-align "
"-Wdisabled-optimization "
"-Winit-self -Winvalid-pch "
"-Wmissing-include-dirs "
"-Wmissing-noreturn "
"-Wpacked -Wredundant-decls "
"-Wformat=2 "
"-Weffc++ "
"-Wctor-dtor-privacy "
"-Wno-unused-parameter "
"-Wshadow "
"-Wnon-virtual-dtor "
"-Wcast-qual "
"-Wold-style-cast "
"-Wzero-as-null-pointer-constant "
"-Wconversion "
"-Wlogical-op "
"-Wstrict-null-sentinel "
"-Wsuggest-override "
)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8)
string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
"${SUPERTUX2_EXTRA_WARNING_FLAGS} "
"-Wint-in-bool-context "
)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
"${SUPERTUX2_EXTRA_WARNING_FLAGS} "
"-Weverything "

# flags that we deliberately ignore
"-Wno-unused-parameter "
"-Wno-unused-template "
"-Wno-c++98-compat "
"-Wno-c++98-compat-pedantic "
"-Wno-float-equal "
"-Wno-padded "
"-Wno-weak-vtables "
"-Wno-disabled-macro-expansion "
"-Wno-documentation "
"-Wno-reserved-id-macro "
"-Wno-sign-conversion "
"-Wno-reserved-identifier "
"-Wno-unknown-warning-option "
set(ALL_WARNING_FLAGS
-Wall -Weverything -Wextra
-fdiagnostics-show-option
-pedantic
-Wno-long-long
-Wcast-align
-Wdisabled-optimization
-Winit-self -Winvalid-pch
-Wmissing-include-dirs
-Wmissing-noreturn
-Wpacked -Wredundant-decls
-Wformat=2
-Weffc++
-Wctor-dtor-privacy
-Wshadow
-Wnon-virtual-dtor
-Wcast-qual
-Wold-style-cast
-Wzero-as-null-pointer-constant
-Wconversion
-Wlogical-op
-Wstrict-null-sentinel
-Wsuggest-override
-Wint-in-bool-context

# warnings that should probably be fixed in code
"-Wno-documentation-unknown-command "
"-Wno-inconsistent-missing-destructor-override "
"-Wno-deprecated-dynamic-exception-spec "
"-Wno-deprecated "
"-Wno-switch-enum "
"-Wno-covered-switch-default "
"-Wno-exit-time-destructors "
"-Wno-global-constructors "
"-Wno-duplicate-enum "
"-Wno-unreachable-code "
)
# flags that we deliberately ignore
-Wno-unused-parameter
-Wno-unused-template
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-float-equal
-Wno-padded
-Wno-weak-vtables
-Wno-disabled-macro-expansion
-Wno-documentation
-Wno-reserved-id-macro
-Wno-sign-conversion
-Wno-reserved-identifier
-Wno-unknown-warning-option

# This snipped adapted from AOMediaCodec cmakefile
# The detection of cross compilation by -Wpoison-system-directories has false positives on macOS because
# --sysroot is implicitly added. Turn the warning off.
if(NOT DEFINED HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
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 ")
# warnings that should probably be fixed in code
-Wno-documentation-unknown-command
-Wno-inconsistent-missing-destructor-override
-Wno-deprecated-dynamic-exception-spec
-Wno-deprecated
-Wno-switch-enum
-Wno-covered-switch-default
-Wno-exit-time-destructors
-Wno-global-constructors
-Wno-duplicate-enum
-Wno-unreachable-code)

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};")
endif()
unset(HAVE_FLAG CACHE)
endforeach(flag IN LISTS ALL_WARNING_FLAGS)

# This snipped adapted from AOMediaCodec cmakefile
# The detection of cross compilation by -Wpoison-system-directories has false positives on macOS because
# --sysroot is implicitly added. Turn the warning off.
if(NOT DEFINED HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
check_cxx_compiler_flag(-Wpoison-system-directories HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
endif()
endif()
if(HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
string(APPEND SUPERTUX2_EXTRA_WARNING_FLAGS "-Wno-poison-system-directories;")
endif()
endif()
endif()

# EOF #
Loading