Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Move disabled warnings so they are always applied
Browse files Browse the repository at this point in the history
  • Loading branch information
EinarElen authored and tomeichlersmith committed Apr 2, 2024
1 parent c2c5c59 commit 6aaf8a9
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@ function(
option(PEDANTIC_WARNINGS "Build LDMX-sw with pedantic compiler warnings enabled" OFF)
option(ADDITIONAL_WARNINGS "Build LDMX-sw with additional compiler warnings enabled" OFF)

if("${DISABLED_WARNINGS}" STREQUAL "")
set(DISABLED_WARNINGS
# These are used so much in ldmx-sw that we can't warn on them
-Wno-old-style-cast # warn for c-style casts
-Wno-unused-parameter
-Wno-sign-conversion # warn on sign conversions
-Wno-conversion # warn on type conversions that may lose data
-Wno-sign-compare
# Do we care about this one?
-Wno-double-promotion # warn if float is implicit promoted to double
# ABI-related warnings that we can't do much about
-Wno-psabi
)
endif()
if (ADDITIONAL_WARNINGS)
if(PEDANTIC_WARNINGS)
set(PEDANTIC_WARNINGS_ENABLED
-Wpedantic # warn if non-standard C++ is used
)
else()
set(PEDANTIC_WARNINGS_ENABLED "")
endif()
endif() # PEDANTIC_WARNINGS
if("${CLANG_WARNINGS}" STREQUAL "")
set(CLANG_WARNINGS
-Wall
Expand All @@ -36,29 +50,17 @@ function(
${DISABLED_WARNINGS}
${PEDANTIC_WARNINGS_ENABLED}
)
endif()
endif() # CLANG_WARNINGS is not set

if("${GCC_WARNINGS}" STREQUAL "")

set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wduplicated-cond # warn if if / else chain has duplicated conditions
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
-Wuseless-cast # warn if you perform a cast to the same type
)
if("${DISABLED_WARNINGS}" STREQUAL "")
set(DISABLED_WARNINGS
# These are used so much in ldmx-sw that we can't warn on them
-Wno-old-style-cast # warn for c-style casts
-Wno-unused-parameter
-Wno-sign-conversion # warn on sign conversions
-Wno-conversion # warn on type conversions that may lose data
-Wno-sign-compare
# Do we care about this one?
-Wno-double-promotion # warn if float is implicit promoted to double
# ABI-related warnings that we can't do much about
-Wno-psabi
)
list(APPEND CLANG_WARNINGS
${DISABLED_WARNINGS}
# Clang is being standards-compliant and forbidding conversions in
Expand All @@ -79,12 +81,14 @@ function(
# https://stackoverflow.com/questions/50646334/maybe-unused-on-member-variable-gcc-warns-incorrectly-that-attribute-is
-Wno-attributes
)
endif()

endif()
endif() # GCC_WARNINGS is not set

endif()

else()
SET(CLANG_WARNINGS "${DISABLED_WARNINGS}")
SET(GCC_WARNINGS "${DISABLED_WARNINGS}")
endif() # ADDITIONAL_WARNINGS

if(WARNINGS_AS_ERRORS)
list(APPEND CLANG_WARNINGS -Werror)
Expand Down

0 comments on commit 6aaf8a9

Please sign in to comment.