From ab046f1dfc7baf4ef2ebe749aa0c8dfaa7c6d13d Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Wed, 3 Aug 2022 09:53:43 -0700 Subject: [PATCH] Define _CRT_SECURE_NO_WARNINGS if MSVC CRT is used Suppress the following MSVC compiler warnings: src\source\cpu_id.cc(140): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. src\source\cpu_id.cc(169): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. Note that build/config/win/BUILD.gn defines _CRT_SECURE_NO_DEPRECATE instead. _CRT_SECURE_NO_WARNINGS is the new name of the macro. See https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-140 Bug: libyuv:939 Change-Id: I0d1715b31e672126c35e29b99f5cbf08e4338f40 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3807104 Reviewed-by: Frank Barchard --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 404c8a674..d190507b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,10 @@ LIST ( SORT ly_unittest_sources ) INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} ) +if(MSVC) + ADD_DEFINITIONS ( -D_CRT_SECURE_NO_WARNINGS ) +endif() + # this creates the static library (.a) ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )