libtiff: cmake: Fixes for Visual Studio 2022

From 42fc3324e177ef21eb752329d7f56f984019b665 Mon Sep 17 00:00:00 2001
From: Roger Leigh <[EMAIL REDACTED]>
Date: Wed, 13 Jul 2022 06:56:03 +0100
Subject: [PATCH] cmake: Fixes for Visual Studio 2022

---
 CMakeLists.txt             |  5 -----
 cmake/WindowsSupport.cmake | 14 +++++++++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 561a5de4..26acca80 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -137,11 +137,6 @@ find_package(CMath REQUIRED)
 # Release support
 include(Release)
 
-if(MSVC)
-    add_compile_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
-    add_compile_options(/wd4996)
-endif()
-
 # Process subdirectories
 add_subdirectory(port)
 add_subdirectory(libtiff)
diff --git a/cmake/WindowsSupport.cmake b/cmake/WindowsSupport.cmake
index 8cfe7ae3..4161880c 100644
--- a/cmake/WindowsSupport.cmake
+++ b/cmake/WindowsSupport.cmake
@@ -23,13 +23,17 @@
 # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 # OF THIS SOFTWARE.
 
-# Debug postfix
 if(MSVC)
+    # Debug postfix
     set(CMAKE_DEBUG_POSTFIX "d")
-# disable deprecation warnings
-    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
-# suppress deprecation warning for MSVC POSIX names
-    add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
+
+    # disable deprecation warnings
+    add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
+    # suppress deprecation warning for MSVC POSIX names
+    add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
+
+    # Don't warn about use of deprecated functions
+    add_compile_options(/wd4996)
 endif()
 
 # Win32 file I/O