From 43363ee0665840218307c37b931d643d54dfbf85 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 31 Aug 2024 19:47:29 +0100 Subject: [PATCH] Disable CRT security warnings in MSVC (#15077) MSVC by default warns if Annex-K style secure functions with additional parameter validation are not used. For better or worse, afaik other major compilers don't implement it, so it's not a very useful warning for a cross-platform project. --- irr/src/CMakeLists.txt | 4 ++++ lib/lua/CMakeLists.txt | 4 ++++ src/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/irr/src/CMakeLists.txt b/irr/src/CMakeLists.txt index 2bc935b9f..161a0c060 100644 --- a/irr/src/CMakeLists.txt +++ b/irr/src/CMakeLists.txt @@ -83,6 +83,10 @@ if(LINUX_PLATFORM) add_definitions(-D_IRR_LINUX_PLATFORM_) endif() +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + if(USE_SDL2) set(DEVICE "SDL") elseif(DEVICE STREQUAL "SDL") diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt index 2de4840cb..869a3c320 100644 --- a/lib/lua/CMakeLists.txt +++ b/lib/lua/CMakeLists.txt @@ -22,6 +22,10 @@ else() set(DEFAULT_ANSI TRUE) endif() +if(MSVC) + set(COMMON_CFLAGS "${COMMON_CFLAGS} -D_CRT_SECURE_NO_WARNINGS") +endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -Wl,-E -lm") set(DEFAULT_DLOPEN ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 955bf05f2..0ea8a40a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -781,7 +781,7 @@ endif() if(MSVC) # Visual Studio - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _WIN32_WINNT=0x0601 /D WIN32_LEAN_AND_MEAN") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _WIN32_WINNT=0x0601 /D WIN32_LEAN_AND_MEAN /D _CRT_SECURE_NO_WARNINGS") # EHa enables SEH exceptions (used for catching segfaults) set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0") if(CMAKE_SIZEOF_VOID_P EQUAL 4)