Define _HAS_EXCEPTIONS=0 when exceptionhandling is "off". (#674)

* Define _HAS_EXCEPTIONS=0 when exceptionhandling is "off".

* Fix unit-test.

* It should be for VS2013 and later only.

* update & add unit-test.
This commit is contained in:
Tom van Dijck 2017-02-03 07:05:23 -08:00 committed by GitHub
parent 0a7b45ce17
commit 5a4ad51aec
3 changed files with 31 additions and 2 deletions

View File

@ -1150,7 +1150,11 @@
function m.clCompilePreprocessorDefinitions(cfg, condition)
m.preprocessorDefinitions(cfg, cfg.defines, false, condition)
local defines = cfg.defines
if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then
defines = table.join(defines, "_HAS_EXCEPTIONS=0")
end
m.preprocessorDefinitions(cfg, defines, false, condition)
end
@ -1965,7 +1969,11 @@
function m.resourcePreprocessorDefinitions(cfg)
m.preprocessorDefinitions(cfg, table.join(cfg.defines, cfg.resdefines), true)
local defines = table.join(cfg.defines, cfg.resdefines)
if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then
table.insert(defines, "_HAS_EXCEPTIONS=0")
end
m.preprocessorDefinitions(cfg, defines, true)
end

View File

@ -157,6 +157,11 @@
for _, define in ipairs(defines) do
table.insert(result, '/D"' .. define .. '"')
end
if cfg and cfg.exceptionhandling == p.OFF then
table.insert(result, "/D_HAS_EXCEPTIONS=0")
end
return result
end

View File

@ -534,6 +534,22 @@
]]
end
function suite.exceptions_onNoExceptionsVS2013()
exceptionhandling "Off"
premake.action.set("vs2013")
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
<ExceptionHandling>false</ExceptionHandling>
]]
end
function suite.exceptions_onSEH()
exceptionhandling "SEH"
prepare()