-
Notifications
You must be signed in to change notification settings - Fork 471
Enable additional compiler warnings for CMake build #283
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
Conversation
@compnerd please comment if there are better ways to do this in CMake. Thanks |
@@ -0,0 +1,85 @@ | |||
|
|||
macro(dispatch_common_warnings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely is problematic. You break cross-compiling for Windows this way. You should check if the compiler flag is supported and if you are using a GNU frontend before adding these options. This is also a very large set of flags that you are adding, maintaining this seems like a headache. How were these handled in autotools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are the flags we have enabled in the darwin build internally (in Xcode, see the .xcconfig files in the repo), so shared code should be built with these enabled to avoid breaking the darwin build (and I want the darwin CMake build to definitely have these so that it matches the Xcode build as closely as possible).
We maintain these flags internally by hand by adding or removing new ones as clang adds support for them (based on -Weverything). Once the opensource buildsystem matches, we can start maintaining these in parallel.
If we need to opt out non-clang platforms like Windows that we don't build & support on a continual basis right now, that is a much lesser concern IMO
tests/CMakeLists.txt
Outdated
@@ -91,7 +91,7 @@ function(add_unit_test name) | |||
if(WITH_BLOCKS_RUNTIME) | |||
target_link_libraries(${name} PRIVATE BlocksRuntime) | |||
endif() | |||
if(BSD_OVERLAY_FOUND) | |||
if(BSD_OVERLAY_FOUND AND (NOT ${name} MATCHES "dispatch_c99")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These exclusions are ugly. How about adding a NO_BSD_OVERLAY
keyword option to the add_unit_test
so that it is generic.
cffdf51
to
881106d
Compare
updated based on review comments. |
@@ -0,0 +1,91 @@ | |||
|
|||
# TODO: really should be checking for clang/gcc compatibile compiler | |||
if(CMAKE_SYSTEM_NAME STREQUAL Windows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
tests/CMakeLists.txt
Outdated
@@ -58,7 +58,7 @@ if(ENABLE_SWIFT) | |||
swiftSwiftOnoneSupport) | |||
endif() | |||
|
|||
function(add_unit_test name) | |||
function(add_unit_test name uses_bsd_overlay) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make this a keyword argument (add NO_BSD_OVERLAY
to the options
list below), you can reference it as AUT_NO_BSD_OVERLAY
then.
881106d
to
d120813
Compare
updated again based on @compnerd feedback |
tests/CMakeLists.txt
Outdated
@@ -60,6 +60,7 @@ endif() | |||
|
|||
function(add_unit_test name) | |||
set(options DISABLED_TEST) | |||
set(options NO_BSD_OVERLAY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This drops the DISABLED_TEST
since you overwrite the variable. Just append to it.
set(options DISABLED_TEST;NO_BSD_OVERLAY)
tests/CMakeLists.txt
Outdated
@@ -138,6 +138,8 @@ set(DISPATCH_C_TESTS | |||
data | |||
io_net | |||
select) | |||
set(DISPATCH_C99_TESTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't bother with a list for a single test. Just inline it below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't drop the DISABLED_TEST
option.
d120813
to
9babf1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Im still not a fan of the management of the warnings, but if everyone else is okay with that, lets go with it.
@dgrove-oss sounds good, I've merged #284 |
argh, and now I re-read what you said and I did it the wrong way around... sorry! |
no worries; I can make it work either way. working on it now |
1. add a CMake module to define additional warning flags to enable when compiling dispatch. 2. enable the additional warning flags by default for CMake 3. match autotools behavior of not including the BSD_OVERLAY when compiling the dispatch_c99 test case. This avoids a warning about __printflike being redefined when compiling this test case with the expanded set of warning flags.
9babf1b
to
0652ef8
Compare
ok. conflicts resolved. should be ready to go. |
thanks! |
Enable additional compiler warnings for CMake build Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
add a CMake module to define additional warning flags to enable
when compiling dispatch.
enable the additional warning flags by default for CMake
match autotools behavior of not including the BSD_OVERLAY
when compiling the dispatch_c99 test case. This avoids
a warning about __printflike being redefined when compiling
this test case with the expanded set of warning flags.