Changeset View
Standalone View
CMakeLists.txt
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
114 | 114 | | |||
115 | function(add_compile_flag_if_supported _flag) | 115 | function(add_compile_flag_if_supported _flag) | ||
116 | unset(_have_flag CACHE) | 116 | unset(_have_flag CACHE) | ||
117 | string(REGEX REPLACE "[-=]" "_" _varname ${_flag}) | 117 | string(REGEX REPLACE "[-=]" "_" _varname ${_flag}) | ||
118 | string(TOUPPER ${_varname} _varname) | 118 | string(TOUPPER ${_varname} _varname) | ||
119 | set(_varname "HAVE${_varname}") | 119 | set(_varname "HAVE${_varname}") | ||
120 | check_cxx_compiler_flag("${_flag}" "${_varname}") | 120 | check_cxx_compiler_flag("${_flag}" "${_varname}") | ||
121 | if (${${_varname}}) | 121 | if (${${_varname}}) | ||
122 | if("${ARGV1}" STREQUAL "CXX_ONLY") | ||||
123 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE) | ||||
124 | else() | ||||
122 | add_compile_options(${_flag}) | 125 | add_compile_options(${_flag}) | ||
123 | endif() | 126 | endif() | ||
127 | endif() | ||||
124 | endfunction() | 128 | endfunction() | ||
125 | 129 | | |||
126 | # Turn off missing-field-initializers warning for GCC to avoid noise from false positives with empty {} | 130 | # Turn off missing-field-initializers warning for GCC to avoid noise from false positives with empty {} | ||
127 | # See discussion: http://mail.kde.org/pipermail/kdevelop-devel/2014-February/046910.html | 131 | # See discussion: http://mail.kde.org/pipermail/kdevelop-devel/2014-February/046910.html | ||
128 | add_compile_flag_if_supported(-Wno-missing-field-initializers) | 132 | add_compile_flag_if_supported(-Wno-missing-field-initializers) | ||
129 | add_compile_flag_if_supported(-Werror=switch) | 133 | add_compile_flag_if_supported(-Werror=switch) | ||
130 | add_compile_flag_if_supported(-Werror=undefined-bool-conversion) | 134 | add_compile_flag_if_supported(-Werror=undefined-bool-conversion) | ||
131 | add_compile_flag_if_supported(-Werror=tautological-undefined-compare) | 135 | add_compile_flag_if_supported(-Werror=tautological-undefined-compare) | ||
132 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | 136 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
133 | add_compile_flag_if_supported(-Wdocumentation) | 137 | add_compile_flag_if_supported(-Wdocumentation) | ||
134 | add_compile_flag_if_supported(-Wcovered-switch-default) | 138 | add_compile_flag_if_supported(-Wcovered-switch-default) | ||
135 | # This warning is triggered by every call to qCDebug() | 139 | # This warning is triggered by every call to qCDebug() | ||
136 | add_compile_flag_if_supported(-Wno-gnu-zero-variadic-macro-arguments) | 140 | add_compile_flag_if_supported(-Wno-gnu-zero-variadic-macro-arguments) | ||
137 | endif() | 141 | endif() | ||
138 | if (CMAKE_COMPILER_CXX_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | 142 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
kossebau: This typo fix would be done as separate commit. So far it had prevented -pedantic to be enabled… | |||||
139 | add_compile_flag_if_supported(-pedantic) | 143 | add_compile_flag_if_supported(-pedantic) | ||
144 | add_compile_flag_if_supported(-Wzero-as-null-pointer-constant CXX_ONLY) | ||||
145 | endif() | ||||
146 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||||
147 | add_compile_flag_if_supported(-Wsuggest-override CXX_ONLY) | ||||
With Clang you could add -Winconsistent-missing-override, although it's not exactly the same. (It's a bit weaker.) aaronpuchert: With Clang you could add `-Winconsistent-missing-override`, although it's not exactly the same. | |||||
A bit weaker might be still better than no strength at all? If so, that one would be a candidate also for https://phabricator.kde.org/source/extra-cmake-modules/browse/master/kde-modules/KDEFrameworkCompilerSettings.cmake (where I took the base snippets from). kossebau: A bit weaker might be still better than no strength at all? If so, that one would be a… | |||||
The docs say the diagnostic "-Winconsistent-missing-override" is "enabled by default.": Other places claim it is part of "-Wall" at least since clang 3.5, but I could not find anything related in the release notes, so far unsure when this was added and when per default enabled. So would you think it is still needed here to try to enable it as well? I would assume disabling it for the 3rd-party makes sense still. kossebau: The docs say the diagnostic "-Winconsistent-missing-override" is "enabled by default.":
https… | |||||
If -Winconsistent-missing-override is on by default, there is nothing you need to do. (I haven't seen the warning for third-party code, so disabling it might also not be necessary.) aaronpuchert: If `-Winconsistent-missing-override` is on by default, there is nothing you need to do. (I… | |||||
Okay, could also not see any traces for such warnings with freebsd clang builds on CI. kossebau: Okay, could also not see any traces for such warnings with freebsd clang builds on CI.
So I… | |||||
140 | endif() | 148 | endif() | ||
141 | 149 | | |||
142 | include_directories(${KDevelop_SOURCE_DIR} ${KDevelop_BINARY_DIR}) | 150 | include_directories(${KDevelop_SOURCE_DIR} ${KDevelop_BINARY_DIR}) | ||
143 | 151 | | |||
144 | string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER) | 152 | string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER) | ||
145 | if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug" | 153 | if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug" | ||
146 | OR CMAKE_BUILD_TYPE_TOLOWER STREQUAL "") | 154 | OR CMAKE_BUILD_TYPE_TOLOWER STREQUAL "") | ||
147 | set(COMPILER_OPTIMIZATIONS_DISABLED TRUE) | 155 | set(COMPILER_OPTIMIZATIONS_DISABLED TRUE) | ||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
This typo fix would be done as separate commit. So far it had prevented -pedantic to be enabled with GCC :)