diff --git a/CMakeLists.txt b/CMakeLists.txt
index a132357f390200b0bc7eb462665f4e226e69b760..7d0973b4a3b4d0d13374c235a84f925c0218440c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -842,6 +842,16 @@ ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
 # line to configure the namespace in the C and C++ source files.
 ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
 
+# Disable deprecation warnings for standard C functions.
+IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$"))
+  ADD_DEFINITIONS(
+    -D_CRT_NONSTDC_NO_DEPRECATE
+    -D_CRT_SECURE_NO_DEPRECATE
+    -D_CRT_SECURE_NO_WARNINGS
+    -D_SCL_SECURE_NO_DEPRECATE
+    )
+ENDIF()
+
 IF(KWSYS_USE_String)
   # Activate code in "String.c".  See the comment in the source.
   SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
diff --git a/Configure.h.in b/Configure.h.in
index 15986cfea731f57975e5a5c209871851f5083eb9..70cf8442beb1fd9de21e8f891bb2c5e925bd0e0d 100644
--- a/Configure.h.in
+++ b/Configure.h.in
@@ -37,20 +37,6 @@
 /* Whether kwsys namespace is "kwsys".  */
 #define @KWSYS_NAMESPACE@_NAME_IS_KWSYS @KWSYS_NAME_IS_KWSYS@
 
-/* If we are building a kwsys .c or .cxx file, suppress the Microsoft
-   deprecation warnings.  */
-#if defined(KWSYS_NAMESPACE)
-# ifndef _CRT_NONSTDC_NO_DEPRECATE
-#  define _CRT_NONSTDC_NO_DEPRECATE
-# endif
-# ifndef _CRT_SECURE_NO_DEPRECATE
-#  define _CRT_SECURE_NO_DEPRECATE
-# endif
-# ifndef _SCL_SECURE_NO_DEPRECATE
-#  define _SCL_SECURE_NO_DEPRECATE
-# endif
-#endif
-
 /* Whether Large File Support is requested.  */
 #define @KWSYS_NAMESPACE@_LFS_REQUESTED @KWSYS_LFS_REQUESTED@