diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 7890733ca..39d09879d 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -1,3 +1,9 @@ + +if(MSVC) + # 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. + add_definitions(/wd4996) +endif() + add_executable(benchncnn benchncnn.cpp) target_link_libraries(benchncnn PRIVATE ncnn) diff --git a/benchmark/benchncnn.cpp b/benchmark/benchncnn.cpp index ea68ea734..26a3dfd2e 100644 --- a/benchmark/benchncnn.cpp +++ b/benchmark/benchncnn.cpp @@ -12,10 +12,6 @@ // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. -#ifdef _WIN32 -#define _CRT_SECURE_NO_WARNINGS -#endif - #include #include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cd56fbefd..f47a752f6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,9 @@ +if(MSVC) + # 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. + add_definitions(/wd4996) +endif() + macro(ncnn_add_test name) add_executable(test_${name} test_${name}.cpp) target_link_libraries(test_${name} PRIVATE ncnn)