Make _CRT_SECURE_NO_WARNINGS a global definition. Introduce mechanism to disable warnings.

This commit is contained in:
Marcel Pi 2024-03-12 23:19:57 +01:00
parent 908b1b306b
commit 07963dba96
2 changed files with 32 additions and 3 deletions

View File

@ -17,4 +17,30 @@ if (ENABLE_ALL_WARNINGS)
add_compile_options (-Wall)
endif ()
endif ()
endif ()
endif ()
macro (carla_try_suppress_cxx_warning NAME FLAG)
check_cxx_compiler_flag (
-Wno-${FLAG}
HAS_${NAME}
)
if (HAS_${NAME})
add_compile_options (
$<$<COMPILE_LANGUAGE:CXX>:-Wno-${FLAG}>
)
endif ()
endmacro ()
set (
CARLA_SUPRESSED_WARNING_LIST
macro-redefined
incompatible-pointer-types
)
foreach (WARNING ${CARLA_SUPRESSED_WARNING_LIST})
string (MAKE_C_IDENTIFIER "${WARNING}" WARNING_NAME)
carla_try_suppress_cxx_warning (
${WARNING_NAME}
${WARNING}
)
endforeach ()

View File

@ -106,9 +106,12 @@ set (
)
if (WIN32)
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
endif ()
if (WIN32)
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
list (APPEND CARLA_COMMON_DEFINITIONS _WIN32_WINNT=0x0601) # --- Windows 10 ---
list (APPEND CARLA_COMMON_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
list (APPEND CARLA_COMMON_DEFINITIONS HAVE_SNPRINTF)
list (APPEND CARLA_COMMON_DEFINITIONS _USE_MATH_DEFINES)
endif ()