Add support for cppdialect in VS2015 & VS2017 actions.

This commit is contained in:
Tom van Dijck 2017-05-24 10:31:18 -07:00
parent 6907f6785c
commit 5251432aec
2 changed files with 111 additions and 2 deletions

View File

@ -343,6 +343,7 @@
m.additionalCompileOptions,
m.compileAs,
m.callingConvention,
m.languageStandard,
}
end
@ -1084,9 +1085,28 @@
end
function m.languageStandard(cfg)
if _ACTION >= "vs2017" then
if (cfg.cppdialect == "C++14") then
m.element("LanguageStandard", nil, 'stdcpp14')
elseif (cfg.cppdialect == "C++17") then
m.element("LanguageStandard", nil, 'stdcpplatest')
end
end
end
function m.additionalCompileOptions(cfg, condition)
if #cfg.buildoptions > 0 then
local opts = table.concat(cfg.buildoptions, " ")
local opts = cfg.buildoptions
if _ACTION == "vs2015" then
if (cfg.cppdialect == "C++14") then
table.insert(opts, "/std:c++14")
elseif (cfg.cppdialect == "C++17") then
table.insert(opts, "/std:c++latest")
end
end
if #opts > 0 then
opts = table.concat(opts, " ")
m.element("AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts)
end
end

View File

@ -1068,3 +1068,92 @@
</ClCompile>
]]
end
--
-- Check handling of the C++14 & C++17 api
--
function suite.onLanguage_Cpp14_VS2010()
cppdialect 'C++14'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
]]
end
function suite.onLanguage_Cpp14_VS2015()
p.action.set("vs2015")
cppdialect 'C++14'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalOptions>/std:c++14 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
]]
end
function suite.onLanguage_Cpp14_VS2017()
p.action.set("vs2017")
cppdialect 'C++14'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<LanguageStandard>stdcpp14</LanguageStandard>
</ClCompile>
]]
end
function suite.onLanguage_Cpp17_VS2010()
cppdialect 'C++17'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
]]
end
function suite.onLanguage_Cpp17_VS2015()
p.action.set("vs2015")
cppdialect 'C++17'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
]]
end
function suite.onLanguage_Cpp17_VS2017()
p.action.set("vs2017")
cppdialect 'C++17'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
]]
end