msvc: quiet uninteresting warnings
authorShawn Hoffman <business@symbrkrs.com>
Wed, 10 Apr 2024 14:15:48 +0000 (07:15 -0700)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 12 Jun 2025 20:10:04 +0000 (22:10 +0200)
src/CMakeLists.txt

index 5798ab0..ae51242 100644 (file)
@@ -17,6 +17,33 @@ message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}")
 
 configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY)
 
+if(MSVC)
+  # Disable some overly-verbose warnings activated by -Wall
+
+  # '<name>': function not inlined
+  add_compile_options(/wd4710)
+
+  # function '<name>' selected for automatic inline expansion
+  add_compile_options(/wd4711)
+
+  # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
+  add_compile_options(/wd5045)
+
+  # '<type>': '4' bytes padding added after data member '<name>'
+  add_compile_options(/wd4820)
+
+  # conversion from '<type1>' to '<type2>', possible loss of data
+  add_compile_options(/wd4242 /wd4244 /wd4267)
+
+  # Disable warning on unsafe string functions
+  add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
+
+  if(MSVC_VERSION GREATER_EQUAL 1913)
+    # Disable warnings from system headers
+    add_compile_options(/external:anglebrackets /external:W0)
+  endif()
+endif()
+
 # Targets
 set(c_sources     ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources" )
 set(c_headers     ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers" )