MSVC: define _CRT_SECURE_NO_WARNINGS for all internal CMake targets

In commit 013abe3206, I add
_CRT_SECURE_NO_WARNINGS definition for all Qt internal module targets,
to suppress MSVC warnings like:
warning C4996: 'strncpy': This function or variable may be unsafe.

However, when compiling some internal tools, such as qmake and qdoc,
such warnings also exist. To suppress this kind of warning entirely,
_CRT_SECURE_NO_WARNINGS definition should be added for all Qt internal
targets when using MSVC compiler.

Pick-to: 6.1
Change-Id: I9c37b20672f9d0f470e3e9ea847e5221f43bfc04
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Li Xinwei 2021-04-20 14:46:20 +08:00
parent e99a883bd3
commit c7a27678d6
2 changed files with 1 additions and 4 deletions

View File

@ -152,6 +152,7 @@ if(WIN32)
target_compile_definitions(PlatformCommonInternal INTERFACE "UNICODE;_UNICODE")
if(MSVC)
target_compile_definitions(PlatformCommonInternal INTERFACE
"_CRT_SECURE_NO_WARNINGS"
"$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:_WINDLL>"
)
endif()

View File

@ -358,10 +358,6 @@ function(qt_internal_add_module target)
)
endif()
if(MSVC)
list(APPEND defines_for_extend_target _CRT_SECURE_NO_WARNINGS)
endif()
qt_internal_extend_target("${target}"
${header_module}
SOURCES ${arg_SOURCES}