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

Optional Werror #459

Merged
merged 1 commit into from
Jun 5, 2023
Merged

Conversation

nosracd
Copy link
Contributor

@nosracd nosracd commented Jun 2, 2023

Unfortunately, it appears that if Werror is turned on in this fashion cmake won't let it be overridden via the usual command-line arguments:

  • -DCMAKE_C_FLAGS="-Wno-error" -DCMAKE_CXX_FLAGS="-Wno-error"
  • --compile-no-warning-as-error

This PR removes all arguments from lcm-lua/CMakeLists.txt which modify the number of warnings and how they're treated, instead preferring opt-in command-line arguments to increase the number of warnings and treat them as errors.

Resolves #457.

@nosracd nosracd requested review from tprk77 and ihilt June 2, 2023 16:02
@@ -9,7 +9,6 @@ set(lcm_lua_sources

add_library(lcm-lua MODULE ${lcm_lua_sources})
set_target_properties(lcm-lua PROPERTIES OUTPUT_NAME "lcm" PREFIX "")
target_compile_options(lcm-lua PRIVATE -Werror -Wall -Wextra)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should only add -Werror -Wall -Wextra to the lcm-lua target. The PRIVATE should change only the target's COMPILE_OPTIONS (and not INTERFACE_COMPILE_OPTIONS). I turned this on because I fixed warnings in lcm-lua, and I wanted to make sure other people would not reintroduce warnings.

Can you please explain why you would want to use --compile-no-warning-as-error? I'm having a hard time thinking of a situation where this would be beneficial.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this some more, and if we want to remove -Werror here we can do so, as long as -Werror is guaranteed to be turned on during CI. It would accomplish the same goal. Either way, I would prefer we keep the other options -Wall -Wextra here. (I do not really agree with the idea of local development using different flags from CI, but I understand the reasoning laid out in #457 (comment).)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes a lot of sense. I agree that we should only remove the flags here that are in duplicate to what CI runs with, which excludes -Wall -Wextra. I've amended the original commit to 2b1d725.

@tprk77
Copy link
Member

tprk77 commented Jun 3, 2023

I've caught up on #457. I must admit, I didn't realize that GCC needs optimization flags turned on for some warnings. Anyway, it seems after #458 that CI is now building a release build with -O3 -DNDEBUG so that should fix the issue with the warnings not being detected correctly. Also, thank you for adding the variable initiations that were missing.

It still seems to me that we should keep the warning flags for the lcm-lua target. Without them, #457 would not have been uncovered.

@nosracd nosracd force-pushed the cmake/no_werror_by_default branch from 5572714 to 2b1d725 Compare June 4, 2023 16:37
@nosracd nosracd requested a review from tprk77 June 4, 2023 16:45
@ihilt ihilt merged commit 75ddf9c into lcm-proj:master Jun 5, 2023
@ihilt ihilt deleted the cmake/no_werror_by_default branch June 5, 2023 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lcm 1.5.0 build issue on linux
3 participants