diff --git a/BUILD.bazel b/BUILD.bazel index a42e5be..de64ee2 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -17,6 +17,13 @@ cc_library( name = "ncrypto", srcs = glob(["src/*.cpp"]), hdrs = glob(["include/*.h", "include/ncrypto/*.h"]), + copts = [ + "-Werror", + "-Wextra", + "-Wno-unused-parameter", + "-Wimplicit-fallthrough", + "-Wno-deprecated-declarations", # OpenSSL 3.0 deprecates many APIs we intentionally use + ], includes = ["include"], local_defines = { "NCRYPTO_BSSL_LIBDECREPIT_MISSING": select( diff --git a/include/ncrypto/aead.h b/include/ncrypto/aead.h index 20cf4df..69de329 100644 --- a/include/ncrypto/aead.h +++ b/include/ncrypto/aead.h @@ -19,7 +19,7 @@ class Aead final { public: Aead() = default; - Aead(const AeadInfo* info, const EVP_AEAD* aead) : info_(info), aead_(aead) {} + Aead(const AeadInfo* info, const EVP_AEAD* aead) : aead_(aead), info_(info) {} Aead(const Aead&) = default; Aead& operator=(const Aead&) = default; NCRYPTO_DISALLOW_MOVE(Aead) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78f61de..4df9bab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,26 @@ add_library(ncrypto ncrypto.cpp engine.cpp aead.cpp) + +# Enable strict warning flags for ncrypto sources only +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") + target_compile_options(ncrypto PRIVATE + -Werror + -Wextra + -Wno-unused-parameter + -Wimplicit-fallthrough + -Wno-deprecated-declarations # OpenSSL 3.0 deprecates many APIs we intentionally use + ) +elseif(MSVC) + target_compile_options(ncrypto PRIVATE + /WX # Treat warnings as errors + /W3 # Warning level 3 (production quality) + /wd4100 # Unreferenced formal parameter (like -Wno-unused-parameter) + /wd4267 # Conversion from 'size_t' to smaller type + /wd4244 # Conversion, possible loss of data + /wd4305 # Truncation from 'int' to 'bool' + /wd4127 # Conditional expression is constant + ) +endif() + if (NCRYPTO_SHARED_LIBS) target_link_libraries(ncrypto PUBLIC OpenSSL::SSL OpenSSL::Crypto) else()