msvc: allow disable permissive checks

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-12-30 11:01:43 +08:00
parent 32457c5538
commit f651116fda
3 changed files with 56 additions and 49 deletions

View File

@ -40,6 +40,7 @@ option(FRAMELESSHELPER_NO_DEBUG_OUTPUT "Suppress the debug messages from Framele
option(FRAMELESSHELPER_NO_BUNDLE_RESOURCE "Do not bundle any resources within FramelessHelper." OFF) option(FRAMELESSHELPER_NO_BUNDLE_RESOURCE "Do not bundle any resources within FramelessHelper." OFF)
option(FRAMELESSHELPER_NO_PRIVATE "Do not use any private functionalities from Qt." OFF) option(FRAMELESSHELPER_NO_PRIVATE "Do not use any private functionalities from Qt." OFF)
option(FRAMELESSHELPER_ENABLE_VCLTL "MSVC only: link to the system MSVCRT/UCRT and get rid of API sets." OFF) option(FRAMELESSHELPER_ENABLE_VCLTL "MSVC only: link to the system MSVCRT/UCRT and get rid of API sets." OFF)
option(FRAMELESSHELPER_NO_PERMISSIVE_CHECKS "MSVC only: disable the additional permissive checks." OFF)
if(FRAMELESSHELPER_NO_BUNDLE_RESOURCE) if(FRAMELESSHELPER_NO_BUNDLE_RESOURCE)
message(WARNING "Nothing will be embeded into FramelessHelper, the chrome buttons will have no icon.") message(WARNING "Nothing will be embeded into FramelessHelper, the chrome buttons will have no icon.")

View File

@ -1,3 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- <!--
MIT License MIT License
@ -22,7 +24,6 @@
SOFTWARE. SOFTWARE.
--> -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="org.wangwenx190.framelesshelper.demo" version="1.0.0.0"/> <assemblyIdentity type="win32" name="org.wangwenx190.framelesshelper.demo" version="1.0.0.0"/>
<description>FramelessHelper Demo</description> <description>FramelessHelper Demo</description>

View File

@ -67,9 +67,6 @@ function(setup_compile_params arg_target)
) )
target_compile_options(${arg_target} PRIVATE target_compile_options(${arg_target} PRIVATE
/bigobj /utf-8 $<$<NOT:$<CONFIG:Debug>>:/fp:fast /GT /Gw /Gy /guard:cf /Zc:inline> /bigobj /utf-8 $<$<NOT:$<CONFIG:Debug>>:/fp:fast /GT /Gw /Gy /guard:cf /Zc:inline>
/Zc:auto /Zc:forScope /Zc:implicitNoexcept /Zc:noexceptTypes /Zc:referenceBinding
/Zc:rvalueCast /Zc:sizedDealloc /Zc:strictStrings /Zc:throwingNew /Zc:trigraphs
/Zc:wchar_t
) )
target_link_options(${arg_target} PRIVATE target_link_options(${arg_target} PRIVATE
$<$<NOT:$<CONFIG:Debug>>:/OPT:REF /OPT:ICF /OPT:LBR /GUARD:CF> $<$<NOT:$<CONFIG:Debug>>:/OPT:REF /OPT:ICF /OPT:LBR /GUARD:CF>
@ -87,6 +84,38 @@ function(setup_compile_params arg_target)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/HIGHENTROPYVA>) target_link_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/HIGHENTROPYVA>)
endif() endif()
if(MSVC_VERSION GREATER_EQUAL 1915) # Visual Studio 2017 version 15.8
target_compile_options(${arg_target} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/JMC>)
endif()
if(MSVC_VERSION GREATER_EQUAL 1920) # Visual Studio 2019 version 16.0
target_link_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/CETCOMPAT>)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_options(${arg_target} PRIVATE /d2FH4)
endif()
endif()
if(MSVC_VERSION GREATER_EQUAL 1925) # Visual Studio 2019 version 16.5
target_compile_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/QIntel-jcc-erratum>) # /Qspectre-load
#elseif(MSVC_VERSION GREATER_EQUAL 1912) # Visual Studio 2017 version 15.5
# target_compile_options(${arg_target} PRIVATE /Qspectre)
endif()
#if((MSVC_VERSION GREATER_EQUAL 1927) AND (CMAKE_SIZEOF_VOID_P EQUAL 8)) # Visual Studio 2019 version 16.7
# target_compile_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/guard:ehcont>)
# target_link_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/guard:ehcont>)
#endif()
if(MSVC_VERSION GREATER_EQUAL 1929) # Visual Studio 2019 version 16.10
target_compile_options(${arg_target} PRIVATE /await:strict)
elseif(MSVC_VERSION GREATER_EQUAL 1900) # Visual Studio 2015
target_compile_options(${arg_target} PRIVATE /await)
endif()
if(MSVC_VERSION GREATER_EQUAL 1930) # Visual Studio 2022 version 17.0
target_compile_options(${arg_target} PRIVATE /options:strict)
endif()
if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS)
target_compile_options(${arg_target} PRIVATE
/Zc:auto /Zc:forScope /Zc:implicitNoexcept /Zc:noexceptTypes /Zc:referenceBinding
/Zc:rvalueCast /Zc:sizedDealloc /Zc:strictStrings /Zc:throwingNew /Zc:trigraphs
/Zc:wchar_t
)
if(MSVC_VERSION GREATER_EQUAL 1900) # Visual Studio 2015 if(MSVC_VERSION GREATER_EQUAL 1900) # Visual Studio 2015
target_compile_options(${arg_target} PRIVATE /Zc:threadSafeInit) target_compile_options(${arg_target} PRIVATE /Zc:threadSafeInit)
endif() endif()
@ -102,15 +131,6 @@ function(setup_compile_params arg_target)
if(MSVC_VERSION GREATER_EQUAL 1914) # Visual Studio 2017 version 15.7 if(MSVC_VERSION GREATER_EQUAL 1914) # Visual Studio 2017 version 15.7
target_compile_options(${arg_target} PRIVATE /Zc:__cplusplus) target_compile_options(${arg_target} PRIVATE /Zc:__cplusplus)
endif() endif()
if(MSVC_VERSION GREATER_EQUAL 1915) # Visual Studio 2017 version 15.8
target_compile_options(${arg_target} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/JMC>)
endif()
if(MSVC_VERSION GREATER_EQUAL 1920) # Visual Studio 2019 version 16.0
target_link_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/CETCOMPAT>)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_options(${arg_target} PRIVATE /d2FH4)
endif()
endif()
if(MSVC_VERSION GREATER_EQUAL 1921) # Visual Studio 2019 version 16.1 if(MSVC_VERSION GREATER_EQUAL 1921) # Visual Studio 2019 version 16.1
target_compile_options(${arg_target} PRIVATE /Zc:char8_t) target_compile_options(${arg_target} PRIVATE /Zc:char8_t)
endif() endif()
@ -121,27 +141,11 @@ function(setup_compile_params arg_target)
target_compile_options(${arg_target} PRIVATE /Zc:hiddenFriend) target_compile_options(${arg_target} PRIVATE /Zc:hiddenFriend)
endif() endif()
if(MSVC_VERSION GREATER_EQUAL 1925) # Visual Studio 2019 version 16.5 if(MSVC_VERSION GREATER_EQUAL 1925) # Visual Studio 2019 version 16.5
target_compile_options(${arg_target} PRIVATE target_compile_options(${arg_target} PRIVATE /Zc:preprocessor /Zc:tlsGuards)
/Zc:preprocessor /Zc:tlsGuards $<$<NOT:$<CONFIG:Debug>>:/QIntel-jcc-erratum> # /Qspectre-load
)
#elseif(MSVC_VERSION GREATER_EQUAL 1912) # Visual Studio 2017 version 15.5
# target_compile_options(${arg_target} PRIVATE /Qspectre)
endif() endif()
#[[if((MSVC_VERSION GREATER_EQUAL 1927) AND (CMAKE_SIZEOF_VOID_P EQUAL 8)) # Visual Studio 2019 version 16.7
target_compile_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/guard:ehcont>)
target_link_options(${arg_target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/guard:ehcont>)
endif()]]
if(MSVC_VERSION GREATER_EQUAL 1928) # Visual Studio 2019 version 16.8 & 16.9 if(MSVC_VERSION GREATER_EQUAL 1928) # Visual Studio 2019 version 16.8 & 16.9
target_compile_options(${arg_target} PRIVATE /Zc:lambda /Zc:zeroSizeArrayNew) target_compile_options(${arg_target} PRIVATE /Zc:lambda /Zc:zeroSizeArrayNew)
endif() endif()
if(MSVC_VERSION GREATER_EQUAL 1929) # Visual Studio 2019 version 16.10
target_compile_options(${arg_target} PRIVATE /await:strict)
elseif(MSVC_VERSION GREATER_EQUAL 1900) # Visual Studio 2015
target_compile_options(${arg_target} PRIVATE /await)
endif()
if(MSVC_VERSION GREATER_EQUAL 1930) # Visual Studio 2022 version 17.0
target_compile_options(${arg_target} PRIVATE /options:strict)
endif()
if(MSVC_VERSION GREATER_EQUAL 1931) # Visual Studio 2022 version 17.1 if(MSVC_VERSION GREATER_EQUAL 1931) # Visual Studio 2022 version 17.1
target_compile_options(${arg_target} PRIVATE /Zc:static_assert) target_compile_options(${arg_target} PRIVATE /Zc:static_assert)
endif() endif()
@ -154,6 +158,7 @@ function(setup_compile_params arg_target)
if(MSVC_VERSION GREATER_EQUAL 1935) # Visual Studio 2022 version 17.5 if(MSVC_VERSION GREATER_EQUAL 1935) # Visual Studio 2022 version 17.5
target_compile_options(${arg_target} PRIVATE /Zc:templateScope /Zc:checkGwOdr) target_compile_options(${arg_target} PRIVATE /Zc:templateScope /Zc:checkGwOdr)
endif() endif()
endif()
else() else()
target_compile_options(${arg_target} PRIVATE target_compile_options(${arg_target} PRIVATE
-Wall -Wextra -Werror -Wall -Wextra -Werror