mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
For each of the recently added warning flags check to see if the
compiler supports the flag before adding it.
This commit is contained in:
parent
0e04e0c305
commit
7676c4d43b
@ -109,32 +109,37 @@ endif()
|
|||||||
# Various compile flags
|
# Various compile flags
|
||||||
add_definitions(-msse2)
|
add_definitions(-msse2)
|
||||||
|
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
macro(check_and_add_flag var flag)
|
||||||
|
CHECK_CXX_COMPILER_FLAG(${flag} FLAG_${var})
|
||||||
|
if(FLAG_${var})
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
# Enabling all warnings in MSVC spams too much
|
# Enabling all warnings in MSVC spams too much
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_definitions(-Wall
|
add_definitions(-Wall)
|
||||||
|
|
||||||
# TODO: would like these but they produce overwhelming amounts of warnings
|
# TODO: would like these but they produce overwhelming amounts of warnings
|
||||||
# -Wextra
|
#check_and_add_flag(EXTRA -Wextra)
|
||||||
# -Wmissing-field-initializers
|
#check_and_add_flag(MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers)
|
||||||
# -Wswitch-default
|
#check_and_add_flag(SWITCH_DEFAULT -Wswitch-default)
|
||||||
# -Wfloat-equal
|
#check_and_add_flag(FLOAT_EQUAL -Wfloat-equal)
|
||||||
# -Wconversion
|
#check_and_add_flag(CONVERSION -Wconversion)
|
||||||
# -Wzero-as-null-pointer-constant
|
#check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant)
|
||||||
-Wtype-limits
|
check_and_add_flag(TYPE_LIMITS -Wtype-limits)
|
||||||
-Wsign-compare
|
check_and_add_flag(SIGN_COMPARE -Wsign-compare)
|
||||||
-Wignored-qualifiers
|
check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers)
|
||||||
-Wuninitialized
|
check_and_add_flag(UNINITIALIZED -Wuninitialized)
|
||||||
-Wshadow
|
check_and_add_flag(LOGICAL_OP -Wlogical-op)
|
||||||
-Winit-self)
|
check_and_add_flag(SHADOW -Wshadow)
|
||||||
if (NOT (${CMAKE_C_COMPILER} MATCHES "clang"))
|
check_and_add_flag(INIT_SELF -Winit-self)
|
||||||
add_definitions(-Wlogical-op)
|
|
||||||
endif()
|
|
||||||
endif(NOT MSVC)
|
endif(NOT MSVC)
|
||||||
|
|
||||||
# gcc uses some optimizations which might break stuff without this flag
|
# gcc uses some optimizations which might break stuff without this flag
|
||||||
add_definitions(-fno-strict-aliasing -fno-exceptions -Wno-psabi)
|
add_definitions(-fno-strict-aliasing -fno-exceptions -Wno-psabi)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
|
|
||||||
# We call fread numerous times without checking return values. Hide the
|
# We call fread numerous times without checking return values. Hide the
|
||||||
# corresponding compiler warnings if the compiler supports doing so.
|
# corresponding compiler warnings if the compiler supports doing so.
|
||||||
CHECK_CXX_COMPILER_FLAG(-Wunused-result NO_UNUSED_RESULT)
|
CHECK_CXX_COMPILER_FLAG(-Wunused-result NO_UNUSED_RESULT)
|
||||||
@ -142,16 +147,10 @@ if(NO_UNUSED_RESULT)
|
|||||||
add_definitions(-Wno-unused-result)
|
add_definitions(-Wno-unused-result)
|
||||||
endif(NO_UNUSED_RESULT)
|
endif(NO_UNUSED_RESULT)
|
||||||
|
|
||||||
CHECK_CXX_COMPILER_FLAG(-fvisibility-inlines-hidden VISIBILITY_INLINES_HIDDEN)
|
check_and_add_flag(VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden)
|
||||||
if(VISIBILITY_INLINES_HIDDEN)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
|
|
||||||
endif(VISIBILITY_INLINES_HIDDEN)
|
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden VISIBILITY_HIDDEN)
|
check_and_add_flag(VISIBILITY_HIDDEN -fvisibility=hidden)
|
||||||
if(VISIBILITY_HIDDEN)
|
|
||||||
add_definitions(-fvisibility=hidden)
|
|
||||||
endif(VISIBILITY_HIDDEN)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
Loading…
Reference in New Issue
Block a user