Skip to content

Commit

Permalink
Disable compiler warnings by default
Browse files Browse the repository at this point in the history
Unconditionally enabling -Werror is a heavy-handed approach and not
ideal when shipping code to be used by many third parties. In fact
it's even better to disable warnings by default since compiler
warnings are not hard requirements. They're merely a development
tool that developers should opt into.
  • Loading branch information
ChrisThrasher authored and tylerjw committed Feb 15, 2024
1 parent cebc67c commit a6803dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ find_package(rclcpp REQUIRED)
find_package(tcb_span REQUIRED)
find_package(tl_expected REQUIRED)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
option(RSL_ENABLE_WARNINGS "Enable compiler warnings" OFF)
if(RSL_ENABLE_WARNINGS AND CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Werror -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wsign-conversion -Wold-style-cast)
endif()

Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_MODULE_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld",
"RSL_BUILD_TESTING": "ON"
"RSL_BUILD_TESTING": "ON",
"RSL_ENABLE_WARNINGS": "ON"
},
"warnings": {
"unusedCli": false
Expand Down

0 comments on commit a6803dc

Please sign in to comment.