From ba74c24d8f0061bf4198cedb2dce831c48d4a780 Mon Sep 17 00:00:00 2001 From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Sun, 8 Sep 2019 14:47:35 +0200 Subject: [PATCH] Added cmake preprocessor definitions when using msvc regarding the 'safe' versions of CRT functions Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a59ddba7..f8e92e250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,8 +203,16 @@ if( WIN32 ) add_definitions( -D__USE_MINGW_ANSI_STDIO=1 ) add_definitions( -DNOMINMAX ) # Get APIs from from Vista onwards. -add_definitions( -D_WIN32_WINNT=0x0601) -add_definitions( -DWINVER=0x0601) +add_definitions( -D_WIN32_WINNT=0x0601 ) +add_definitions( -DWINVER=0x0601 ) + if( MSVC ) + # Use automatic overload for suitable CRT safe-functions + # See https://docs.microsoft.com/de-de/cpp/c-runtime-library/security-features-in-the-crt?view=vs-2019 + add_definitions( -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 ) + # Also: Disable compiler warnings because we don't use Windows CRT safe-functions explicitly and don't intend to + # as this is a pure cross-platform source the only alternative would be a ton of ifdefs with calls to the _s version + add_definitions( -D_CRT_SECURE_NO_WARNINGS ) + endif( MSVC ) endif( WIN32 ) if (APPLE) -- 2.30.2