Improve external include & warning support
This commit is contained in:
parent
24e5c8d2ab
commit
065b3acb2f
@ -1,7 +1,7 @@
|
||||
project "curl-lib"
|
||||
language "C"
|
||||
kind "StaticLib"
|
||||
sysincludedirs { "include" }
|
||||
externalincludedirs { "include" }
|
||||
includedirs { "lib", "../mbedtls/include" }
|
||||
defines { "BUILDING_LIBCURL", "CURL_STATICLIB", "HTTP_ONLY" }
|
||||
warnings "off"
|
||||
|
@ -197,10 +197,10 @@
|
||||
end
|
||||
|
||||
local toolset = m.getcompiler(cfg)
|
||||
local sysincludedirs = toolset.getincludedirs(cfg, {}, cfg.sysincludedirs, cfg.frameworkdirs)
|
||||
local externalincludedirs = toolset.getincludedirs(cfg, {}, cfg.externalincludedirs, cfg.frameworkdirs)
|
||||
local forceincludes = toolset.getforceincludes(cfg)
|
||||
local cxxflags = table.concat(table.join(sysincludedirs, toolset.getcxxflags(cfg), forceincludes, cfg.buildoptions), ";")
|
||||
local cflags = table.concat(table.join(sysincludedirs, toolset.getcflags(cfg), forceincludes, cfg.buildoptions), ";")
|
||||
local cxxflags = table.concat(table.join(externalincludedirs, toolset.getcxxflags(cfg), forceincludes, cfg.buildoptions), ";")
|
||||
local cflags = table.concat(table.join(externalincludedirs, toolset.getcflags(cfg), forceincludes, cfg.buildoptions), ";")
|
||||
local asmflags = ""
|
||||
local pch = p.tools.gcc.getpch(cfg)
|
||||
local usepch = "yes"
|
||||
@ -248,7 +248,7 @@
|
||||
local options = table.concat(cfg.resoptions, ";")
|
||||
|
||||
_x(3, '<ResourceCompiler Options="%s%s" Required="yes">', defines, options)
|
||||
for _, includepath in ipairs(table.join(cfg.sysincludedirs, cfg.includedirs, cfg.resincludedirs)) do
|
||||
for _, includepath in ipairs(table.join(cfg.externalincludedirs, cfg.includedirs, cfg.resincludedirs)) do
|
||||
_x(4, '<IncludePath Value="%s"/>', project.getrelative(cfg.project, includepath))
|
||||
end
|
||||
_p(3, '</ResourceCompiler>')
|
||||
|
@ -77,7 +77,7 @@
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_SysIncludes()
|
||||
sysincludedirs { "sysdir", "sysdir2/"}
|
||||
externalincludedirs { "sysdir", "sysdir2/"}
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
@ -188,7 +188,7 @@
|
||||
|
||||
function suite.OnProjectCfg_ResSysInclude()
|
||||
files { "x.rc" }
|
||||
sysincludedirs { "sysdir/" }
|
||||
externalincludedirs { "sysdir/" }
|
||||
prepare()
|
||||
codelite.project.resourceCompiler(cfg)
|
||||
test.capture [[
|
||||
|
@ -521,7 +521,7 @@ end
|
||||
|
||||
|
||||
function make.includes(cfg, toolset)
|
||||
local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.frameworkdirs)
|
||||
local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs, cfg.frameworkdirs)
|
||||
_p(' INCLUDES +=%s', make.list(includes))
|
||||
end
|
||||
|
||||
|
@ -386,7 +386,7 @@
|
||||
|
||||
|
||||
function cpp.includes(cfg, toolset)
|
||||
local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.frameworkdirs)
|
||||
local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs, cfg.frameworkdirs)
|
||||
p.outln('INCLUDES +=' .. gmake2.list(includes))
|
||||
end
|
||||
|
||||
@ -531,8 +531,8 @@
|
||||
end
|
||||
end
|
||||
|
||||
if fcfg.includedirs or fcfg.sysincludedirs or fcfg.frameworkdirs then
|
||||
local includes = toolset.getincludedirs(cfg, fcfg.includedirs, fcfg.sysincludedirs, fcfg.frameworkdirs)
|
||||
if fcfg.includedirs or fcfg.externalincludedirs or fcfg.frameworkdirs then
|
||||
local includes = toolset.getincludedirs(cfg, fcfg.includedirs, fcfg.externalincludedirs, fcfg.frameworkdirs)
|
||||
if #includes > 0 then
|
||||
value = value .. gmake2.list(includes)
|
||||
end
|
||||
|
@ -142,6 +142,16 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
p.api.register {
|
||||
name = "externalanglebrackets",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
"On",
|
||||
"Off",
|
||||
},
|
||||
}
|
||||
|
||||
p.api.register { -- DEPRECATED 2019-10-21
|
||||
name = "debuggerflavor",
|
||||
scope = "config",
|
||||
@ -174,5 +184,6 @@
|
||||
_ACTION == "vs2015" or
|
||||
_ACTION == "vs2017" or
|
||||
_ACTION == "vs2019" or
|
||||
_ACTION == "vs2022" or
|
||||
false;
|
||||
end
|
||||
|
@ -104,5 +104,7 @@ return {
|
||||
"vc2019/test_toolset_settings.lua",
|
||||
|
||||
-- Visual Studio 2022+ C/C++ Projects
|
||||
"vc2022/test_compile_settings.lua",
|
||||
"vc2022/test_output_props.lua",
|
||||
"vc2022/test_toolset_settings.lua"
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ command 2</NMakeBuildCommandLine>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onSysIncludeDirs()
|
||||
sysincludedirs { "include/lua", "include/zlib" }
|
||||
function suite.onExternalIncludeDirs()
|
||||
externalincludedirs { "include/lua", "include/zlib" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
@ -222,8 +222,8 @@
|
||||
-- Check the handling of the VC++ Directories.
|
||||
--
|
||||
|
||||
function suite.onSystemIncludeDirs()
|
||||
sysincludedirs { "$(DXSDK_DIR)/Include" }
|
||||
function suite.onExternalIncludeDirs()
|
||||
externalincludedirs { "$(DXSDK_DIR)/Include" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
118
modules/vstudio/tests/vc2022/test_compile_settings.lua
Normal file
118
modules/vstudio/tests/vc2022/test_compile_settings.lua
Normal file
@ -0,0 +1,118 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2022/test_compile_settings.lua
|
||||
-- Validate compiler settings in Visual Studio 2022 C/C++ projects.
|
||||
-- Copyright (c) 2011-2021 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("vstudio_vs2022_compile_settings")
|
||||
local vc2010 = p.vstudio.vc2010
|
||||
local project = p.project
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
p.action.set("vs2022")
|
||||
wks, prj = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare(platform)
|
||||
local cfg = test.getconfig(prj, "Debug", platform)
|
||||
vc2010.clCompile(cfg)
|
||||
end
|
||||
|
||||
--
|
||||
-- Check ClCompile for ExternalWarningLevel
|
||||
--
|
||||
function suite.ExternalWarningLevelOff()
|
||||
externalwarnings "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.ExternalWarningLevelDefault()
|
||||
externalwarnings "Default"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>Level3</ExternalWarningLevel>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.ExternalWarningLevelHigh()
|
||||
externalwarnings "High"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>Level4</ExternalWarningLevel>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.ExternalWarningLevelExtra()
|
||||
externalwarnings "Extra"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>Level4</ExternalWarningLevel>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.ExternalWarningLevelEverything()
|
||||
externalwarnings "Everything"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>Level4</ExternalWarningLevel>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check ClCompile for TreatAngleIncludeAsExternal
|
||||
--
|
||||
function suite.TreatAngleIncludeAsExternalOn()
|
||||
externalanglebrackets "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>Level3</ExternalWarningLevel>
|
||||
<TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.TreatAngleIncludeAsExternalOff()
|
||||
externalanglebrackets "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExternalWarningLevel>Level3</ExternalWarningLevel>
|
||||
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
|
||||
]]
|
||||
end
|
45
modules/vstudio/tests/vc2022/test_output_props.lua
Normal file
45
modules/vstudio/tests/vc2022/test_output_props.lua
Normal file
@ -0,0 +1,45 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2022/test_output_props.lua
|
||||
-- Validate generation of the output property groups.
|
||||
-- Copyright (c) 2021 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("vstudio_vs2022_output_props")
|
||||
local vc2010 = p.vstudio.vc2010
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
p.action.set("vs2022")
|
||||
wks, prj = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
local cfg = test.getconfig(prj, "Debug")
|
||||
vc2010.outputProperties(cfg)
|
||||
end
|
||||
|
||||
--
|
||||
-- Check the handling of the VC++ Directories.
|
||||
--
|
||||
|
||||
function suite.onExternalIncludeDirs()
|
||||
externalincludedirs { "src/include" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>bin\Debug\</OutDir>
|
||||
<IntDir>obj\Debug\</IntDir>
|
||||
<TargetName>MyProject</TargetName>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
<ExternalIncludePath>src\include;$(ExternalIncludePath)</ExternalIncludePath>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_compile_settings.lua
|
||||
-- tests/actions/vstudio/vc2022/test_compile_settings.lua
|
||||
-- Validate compiler settings in Visual Studio 2022 C/C++ projects.
|
||||
-- Copyright (c) 2011-2021 Jason Perkins and the Premake project
|
||||
--
|
||||
|
@ -395,6 +395,8 @@
|
||||
m.useFullPaths,
|
||||
m.removeUnreferencedCodeData,
|
||||
m.compileAsWinRT,
|
||||
m.externalWarningLevel,
|
||||
m.externalAngleBrackets,
|
||||
}
|
||||
|
||||
if cfg.kind == p.STATICLIB then
|
||||
@ -818,6 +820,8 @@
|
||||
m.runtimeTypeInfo,
|
||||
m.warningLevelFile,
|
||||
m.compileAsWinRT,
|
||||
m.externalWarningLevel,
|
||||
m.externalAngleBrackets,
|
||||
}
|
||||
else
|
||||
return {
|
||||
@ -2154,9 +2158,13 @@
|
||||
|
||||
|
||||
function m.includePath(cfg)
|
||||
local dirs = vstudio.path(cfg, cfg.sysincludedirs)
|
||||
local dirs = vstudio.path(cfg, cfg.externalincludedirs)
|
||||
if #dirs > 0 then
|
||||
m.element("IncludePath", nil, "%s;$(IncludePath)", table.concat(dirs, ";"))
|
||||
if _ACTION < "vs2022" then
|
||||
m.element("IncludePath", nil, "%s;$(IncludePath)", table.concat(dirs, ";"))
|
||||
else
|
||||
m.element("ExternalIncludePath", nil, "%s;$(ExternalIncludePath)", table.concat(dirs, ";"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -2596,7 +2604,8 @@
|
||||
|
||||
|
||||
function m.resourceAdditionalIncludeDirectories(cfg)
|
||||
m.additionalIncludeDirectories(cfg, table.join(cfg.includedirs, cfg.resincludedirs))
|
||||
local dirs = table.join(cfg.includedirs, cfg.resincludedirs)
|
||||
m.additionalIncludeDirectories(cfg, dirs)
|
||||
end
|
||||
|
||||
|
||||
@ -2845,6 +2854,25 @@
|
||||
end
|
||||
|
||||
|
||||
function m.externalWarningLevel(cfg)
|
||||
if _ACTION >= "vs2022" then
|
||||
local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "Level4", Everything = "Level4" }
|
||||
m.element("ExternalWarningLevel", nil, map[cfg.externalwarnings] or "Level3")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.externalAngleBrackets(cfg)
|
||||
if _ACTION >= "vs2022" then
|
||||
if cfg.externalanglebrackets == p.OFF then
|
||||
m.element("TreatAngleIncludeAsExternal", condition, "false")
|
||||
elseif cfg.externalanglebrackets == p.ON then
|
||||
m.element("TreatAngleIncludeAsExternal", condition, "true")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.xmlDeclaration()
|
||||
p.xmlUtf8()
|
||||
end
|
||||
|
@ -2398,8 +2398,8 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnSysIncludeDirs()
|
||||
sysincludedirs { "../include", "../libs", "../name with spaces" }
|
||||
function suite.XCBuildConfigurationProject_OnExternalIncludeDirs()
|
||||
externalincludedirs { "../include", "../libs", "../name with spaces" }
|
||||
prepare()
|
||||
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
|
||||
test.capture [[
|
||||
@ -3489,7 +3489,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCpp11()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("C++11")
|
||||
@ -3567,7 +3567,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCpp1y()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("C++1y")
|
||||
@ -3619,7 +3619,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCpp1z()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("C++1z")
|
||||
@ -3671,7 +3671,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCpp2a()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("C++2a")
|
||||
@ -3749,7 +3749,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCppGnu0x()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("gnu++0x")
|
||||
@ -3801,7 +3801,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCppGnu1y()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("gnu++1y")
|
||||
@ -3853,7 +3853,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCppGnu1z()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("gnu++1z")
|
||||
@ -3905,7 +3905,7 @@
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnCppGnu2a()
|
||||
workspace("MyWorkspace")
|
||||
cppdialect("gnu++2a")
|
||||
|
@ -1521,14 +1521,14 @@
|
||||
end
|
||||
settings['USER_HEADER_SEARCH_PATHS'] = cfg.includedirs
|
||||
|
||||
local sysincludedirs = project.getrelative(cfg.project, cfg.sysincludedirs)
|
||||
for i,v in ipairs(sysincludedirs) do
|
||||
cfg.sysincludedirs[i] = p.quoted(v)
|
||||
local externalincludedirs = project.getrelative(cfg.project, cfg.externalincludedirs)
|
||||
for i,v in ipairs(externalincludedirs) do
|
||||
cfg.externalincludedirs[i] = p.quoted(v)
|
||||
end
|
||||
if not table.isempty(cfg.sysincludedirs) then
|
||||
table.insert(cfg.sysincludedirs, "$(inherited)")
|
||||
if not table.isempty(cfg.externalincludedirs) then
|
||||
table.insert(cfg.externalincludedirs, "$(inherited)")
|
||||
end
|
||||
settings['SYSTEM_HEADER_SEARCH_PATHS'] = cfg.sysincludedirs
|
||||
settings['SYSTEM_HEADER_SEARCH_PATHS'] = cfg.externalincludedirs
|
||||
|
||||
for i,v in ipairs(cfg.libdirs) do
|
||||
cfg.libdirs[i] = p.project.getrelative(cfg.project, cfg.libdirs[i])
|
||||
@ -1536,7 +1536,7 @@
|
||||
for i,v in ipairs(cfg.syslibdirs) do
|
||||
cfg.syslibdirs[i] = p.project.getrelative(cfg.project, cfg.syslibdirs[i])
|
||||
end
|
||||
settings['LIBRARY_SEARCH_PATHS'] = table.join (cfg.libdirs, cfg.syslibdirs)
|
||||
settings['LIBRARY_SEARCH_PATHS'] = table.join (cfg.libdirs, cfg.syslibdirs)
|
||||
|
||||
for i,v in ipairs(cfg.frameworkdirs) do
|
||||
cfg.frameworkdirs[i] = p.project.getrelative(cfg.project, cfg.frameworkdirs[i])
|
||||
|
@ -1162,13 +1162,6 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "sysincludedirs",
|
||||
scope = "config",
|
||||
kind = "list:directory",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "syslibdirs",
|
||||
scope = "config",
|
||||
@ -1469,6 +1462,38 @@
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "externalincludedirs",
|
||||
scope = "config",
|
||||
kind = "list:directory",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "externalwarnings",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
"Off",
|
||||
"Default",
|
||||
"High",
|
||||
"Extra",
|
||||
"Everything",
|
||||
}
|
||||
}
|
||||
|
||||
api.register { -- DEPRECATED 2021-11-16
|
||||
name = "sysincludedirs",
|
||||
scope = "config",
|
||||
kind = "list:directory",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.deprecateField("sysincludedirs", 'Use `externalincludedirs` instead.',
|
||||
function(value)
|
||||
externalincludedirs(value)
|
||||
end)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
--
|
||||
-- Field name aliases for backward compatibility
|
||||
|
@ -186,10 +186,10 @@
|
||||
-- An array of symbols with the appropriate flag decorations.
|
||||
--
|
||||
|
||||
function clang.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
|
||||
function clang.getincludedirs(cfg, dirs, extdirs, frameworkdirs)
|
||||
|
||||
-- Just pass through to GCC for now
|
||||
local flags = gcc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
|
||||
local flags = gcc.getincludedirs(cfg, dirs, extdirs, frameworkdirs)
|
||||
return flags
|
||||
|
||||
end
|
||||
|
@ -107,6 +107,12 @@
|
||||
Extra = {"-Wall", "-Wextra"},
|
||||
Everything = "-Weverything",
|
||||
},
|
||||
externalwarnings = {
|
||||
Default = "-Wsystem-headers",
|
||||
High = "-Wsystem-headers",
|
||||
Extra = "-Wsystem-headers",
|
||||
Everything = "-Wsystem-headers",
|
||||
},
|
||||
symbols = function(cfg, mappings)
|
||||
local values = gcc.getdebugformat(cfg)
|
||||
local debugformat = values[cfg.debugformat] or ""
|
||||
@ -287,7 +293,7 @@
|
||||
-- Decorate include file search paths for the GCC command line.
|
||||
--
|
||||
|
||||
function gcc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
|
||||
function gcc.getincludedirs(cfg, dirs, extdirs, frameworkdirs)
|
||||
local result = {}
|
||||
for _, dir in ipairs(dirs) do
|
||||
dir = project.getrelative(cfg.project, dir)
|
||||
@ -301,10 +307,11 @@
|
||||
end
|
||||
end
|
||||
|
||||
for _, dir in ipairs(sysdirs or {}) do
|
||||
for _, dir in ipairs(extdirs or {}) do
|
||||
dir = project.getrelative(cfg.project, dir)
|
||||
table.insert(result, '-isystem ' .. p.quoted(dir))
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
@ -96,6 +96,16 @@
|
||||
Extra = "/W4",
|
||||
Everything = "/Wall",
|
||||
},
|
||||
externalwarnings = {
|
||||
Off = "/external:W0",
|
||||
Default = "/external:W3",
|
||||
High = "/external:W4",
|
||||
Extra = "/external:W4",
|
||||
Everything = "/external:W4",
|
||||
},
|
||||
externalanglebrackets = {
|
||||
On = "/external:anglebrackets",
|
||||
},
|
||||
staticruntime = {
|
||||
-- this option must always be emit (does it??)
|
||||
_ = function(cfg) return getRuntimeFlag(cfg, false) end,
|
||||
@ -237,13 +247,22 @@
|
||||
-- Decorate include file search paths for the MSVC command line.
|
||||
--
|
||||
|
||||
function msc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
|
||||
function msc.getincludedirs(cfg, dirs, extdirs, frameworkdirs)
|
||||
local result = {}
|
||||
dirs = table.join(dirs, sysdirs)
|
||||
for _, dir in ipairs(dirs) do
|
||||
dir = project.getrelative(cfg.project, dir)
|
||||
table.insert(result, '-I' .. p.quoted(dir))
|
||||
end
|
||||
|
||||
for _, dir in ipairs(extdirs or {}) do
|
||||
dir = project.getrelative(cfg.project, dir)
|
||||
if cfg.toolset and cfg.toolset >= "msc-v143" then
|
||||
table.insert(result, '/external:I' .. p.quoted(dir))
|
||||
else
|
||||
table.insert(result, '-I' .. p.quoted(dir))
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
@ -80,6 +80,12 @@
|
||||
test.contains({ "-w" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onDefaultWarnings()
|
||||
warnings "Default"
|
||||
prepare()
|
||||
test.excludes({ "-w", "-Wall", "-Wextra", "-Weverything" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onHighWarnings()
|
||||
warnings "High"
|
||||
prepare()
|
||||
@ -112,6 +118,36 @@
|
||||
test.contains({ "-Wenable", "-Wno-disable", "-Werror=fatal" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onNoExternalWarnings()
|
||||
externalwarnings "Off"
|
||||
prepare()
|
||||
test.excludes({ "-Wsystem-headers" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onDefaultExternalWarnings()
|
||||
externalwarnings "Default"
|
||||
prepare()
|
||||
test.contains({ "-Wsystem-headers" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onHighExternalWarnings()
|
||||
externalwarnings "High"
|
||||
prepare()
|
||||
test.contains({ "-Wsystem-headers" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onExtraExternalWarnings()
|
||||
externalwarnings "Extra"
|
||||
prepare()
|
||||
test.contains({ "-Wsystem-headers" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onEverythingExternalWarnings()
|
||||
externalwarnings "Everything"
|
||||
prepare()
|
||||
test.contains({ "-Wsystem-headers" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onFloastFast()
|
||||
floatingpoint "Fast"
|
||||
prepare()
|
||||
@ -393,7 +429,7 @@
|
||||
prepare()
|
||||
test.contains({ "-dynamiclib" }, gcc.getldflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check Mac OS X deployment target flags
|
||||
--
|
||||
@ -404,14 +440,14 @@
|
||||
prepare()
|
||||
test.contains({ "-mmacosx-version-min=10.9" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
function suite.cxxflags_macosx_systemversion()
|
||||
system "MacOSX"
|
||||
systemversion "10.9:10.15"
|
||||
prepare()
|
||||
test.contains({ "-mmacosx-version-min=10.9" }, gcc.getcxxflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
function suite.cxxflags_macosx_systemversion_unspecified()
|
||||
system "MacOSX"
|
||||
prepare()
|
||||
@ -600,8 +636,9 @@
|
||||
|
||||
function suite.includeDirsAreRelative()
|
||||
includedirs { "../include", "src/include" }
|
||||
externalincludedirs { "test/include" }
|
||||
prepare()
|
||||
test.isequal({ '-I../include', '-Isrc/include' }, gcc.getincludedirs(cfg, cfg.includedirs))
|
||||
test.isequal({ '-I../include', '-Isrc/include', '-isystem test/include' }, gcc.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs))
|
||||
end
|
||||
|
||||
|
||||
@ -623,14 +660,16 @@
|
||||
|
||||
function suite.includeDirs_onSpaces()
|
||||
includedirs { "include files" }
|
||||
externalincludedirs { "test include" }
|
||||
prepare()
|
||||
test.isequal({ '-I"include files"' }, gcc.getincludedirs(cfg, cfg.includedirs))
|
||||
test.isequal({ '-I"include files"', '-isystem "test include"' }, gcc.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs))
|
||||
end
|
||||
|
||||
function suite.includeDirs_onEnvVars()
|
||||
includedirs { "$(IntDir)/includes" }
|
||||
externalincludedirs { "$(BinDir)/include" }
|
||||
prepare()
|
||||
test.isequal({ '-I"$(IntDir)/includes"' }, gcc.getincludedirs(cfg, cfg.includedirs))
|
||||
test.isequal({ '-I"$(IntDir)/includes"', '-isystem "$(BinDir)/include"' }, gcc.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs))
|
||||
end
|
||||
|
||||
|
||||
@ -668,12 +707,6 @@
|
||||
-- Check handling of system search paths.
|
||||
--
|
||||
|
||||
function suite.includeDirs_onSysIncludeDirs()
|
||||
sysincludedirs { "/usr/local/include" }
|
||||
prepare()
|
||||
test.contains("-isystem /usr/local/include", gcc.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs))
|
||||
end
|
||||
|
||||
function suite.libDirs_onSysLibDirs()
|
||||
syslibdirs { "/usr/local/lib" }
|
||||
prepare()
|
||||
@ -700,9 +733,9 @@
|
||||
function suite.includeDirs_macosx_onFrameworkDirs()
|
||||
system "MacOSX"
|
||||
location "subdir"
|
||||
frameworkdirs {
|
||||
frameworkdirs {
|
||||
"/Library/Frameworks",
|
||||
"subdir/Relative/Frameworks"
|
||||
"subdir/Relative/Frameworks"
|
||||
}
|
||||
prepare()
|
||||
test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
|
||||
@ -712,7 +745,7 @@
|
||||
function suite.libDirs_macosx_onFrameworkDirs()
|
||||
system "MacOSX"
|
||||
location "subdir"
|
||||
frameworkdirs {
|
||||
frameworkdirs {
|
||||
"/Library/Frameworks",
|
||||
"subdir/Relative/Frameworks"
|
||||
}
|
||||
|
@ -257,6 +257,58 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling externalwarnings.
|
||||
--
|
||||
|
||||
function suite.cflags_onNoExternalWarnings()
|
||||
externalwarnings "Off"
|
||||
prepare()
|
||||
test.contains("/external:W0", msc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onHighExternalWarnings()
|
||||
externalwarnings "High"
|
||||
prepare()
|
||||
test.contains("/external:W4", msc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onExtraExternalWarnings()
|
||||
externalwarnings "Extra"
|
||||
prepare()
|
||||
test.contains("/external:W4", msc.getcflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling externalanglebrackets.
|
||||
--
|
||||
|
||||
function suite.cflags_onExternalAngleBrackets()
|
||||
externalanglebrackets "On"
|
||||
prepare()
|
||||
test.contains("/external:anglebrackets", msc.getcflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling externalincludedirs.
|
||||
--
|
||||
|
||||
function suite.cflags_onExternalIncludeDirs()
|
||||
externalincludedirs { "/usr/local/include" }
|
||||
prepare()
|
||||
test.contains("-I/usr/local/include", msc.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs))
|
||||
end
|
||||
|
||||
function suite.cflags_onVs2022ExternalIncludeDirs()
|
||||
p.action.set("vs2022")
|
||||
externalincludedirs { "/usr/local/include" }
|
||||
prepare()
|
||||
test.contains("/external:I/usr/local/include", msc.getincludedirs(cfg, cfg.includedirs, cfg.externalincludedirs))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of library search paths.
|
||||
--
|
||||
@ -481,12 +533,6 @@
|
||||
-- Check handling of system search paths.
|
||||
--
|
||||
|
||||
function suite.includeDirs_onSysIncludeDirs()
|
||||
sysincludedirs { "/usr/local/include" }
|
||||
prepare()
|
||||
test.contains("-I/usr/local/include", msc.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs))
|
||||
end
|
||||
|
||||
function suite.libDirs_onSysLibDirs()
|
||||
syslibdirs { "/usr/local/lib" }
|
||||
prepare()
|
||||
|
@ -76,7 +76,10 @@
|
||||
| [entrypoint](entrypoint.md) | Specify the program entry point function |
|
||||
| [exceptionhandling](exceptionhandling.md) | Enable or disable exception handling |
|
||||
| [external](external.md) | |
|
||||
| [externalanglebrackets](externalanglebrackets.md) | |
|
||||
| [externalincludedirs](externalincludedirs.md) | |
|
||||
| [externalrule](externalrule.md) | |
|
||||
| [externalwarnings](externalwarnings.md) | |
|
||||
| [fatalwarnings](fatalwarnings.md) | |
|
||||
| [fileextension](fileextension.md) | |
|
||||
| [filename](filename.md) | |
|
||||
|
@ -70,6 +70,9 @@ title: What's New in 5.0
|
||||
* [entrypoint](entrypoint.md) (new)
|
||||
* [exceptionhandling](exceptionhandling.md) (new)
|
||||
* [external](external.md) (new)
|
||||
* [externalanglebrackets](externalanglebrackets.md) (new)
|
||||
* [externalincludedirs](externalincludedirs.md) (new)
|
||||
* [externalwarnings](externalwarnings.md) (new)
|
||||
* [externalproject](externalproject.md) (new)
|
||||
* [externalrule](externalrule.md) (new)
|
||||
* [fatalwarnings](fatalwarnings.md) (new)
|
||||
|
28
website/docs/externalanglebrackets.md
Normal file
28
website/docs/externalanglebrackets.md
Normal file
@ -0,0 +1,28 @@
|
||||
Treats all headers included by `#include <header>`, where the header file is enclosed in angle brackets (`< >`), as external headers.
|
||||
|
||||
```lua
|
||||
externalanglebrackets "value"
|
||||
```
|
||||
|
||||
### Parameters ###
|
||||
|
||||
`value` is one of:
|
||||
|
||||
| Value | Description |
|
||||
|---------|---------------------------------------------------|
|
||||
| On | Treat headers included with angle brackets as external. |
|
||||
| Off | Default. Headers are treated normally. |
|
||||
|
||||
### Applies To ###
|
||||
|
||||
Project configurations.
|
||||
|
||||
### Availability ###
|
||||
|
||||
Premake 5.0 or later.
|
||||
Visual Studio 2022 version 17.0 or later.
|
||||
|
||||
### See Also ###
|
||||
|
||||
* [externalincludedirs](externalincludedirs.md)
|
||||
* [externalwarnings](externalwarnings.md)
|
41
website/docs/externalincludedirs.md
Normal file
41
website/docs/externalincludedirs.md
Normal file
@ -0,0 +1,41 @@
|
||||
Specifies the include file search paths for the compiler, treating headers included from these paths as external.
|
||||
|
||||
```lua
|
||||
externalincludedirs { "paths" }
|
||||
```
|
||||
|
||||
For Visual Studio, these paths are placed in the "VC++ Directories" properties panel. For GCC and Clang, they are preceded with the `-isystem` flag, rather than `-I`. For toolsets which do not support the concept of external include directories, they are treated as a normal include directory.
|
||||
|
||||
Include files located via an external include directory are treated specially, see [externalwarnings](externalwarnings.md).
|
||||
|
||||
### Parameters ###
|
||||
|
||||
`paths` specifies a list of include file search directories. Paths should be specified relative to the currently running script file.
|
||||
|
||||
### Applies To ###
|
||||
|
||||
Project configurations.
|
||||
|
||||
### Availability ###
|
||||
|
||||
Premake 5.0 or later.
|
||||
|
||||
### Examples ###
|
||||
|
||||
Define two external include file search paths.
|
||||
|
||||
```lua
|
||||
externalincludedirs { "../lua/include", "../zlib" }
|
||||
```
|
||||
|
||||
You can also use wildcards to match multiple directories. The * will match against a single directory, ** will recurse into subdirectories as well.
|
||||
|
||||
```lua
|
||||
externalincludedirs { "../includes/**" }
|
||||
```
|
||||
|
||||
### See Also ###
|
||||
|
||||
* [externalanglebrackets](externalanglebrackets.md)
|
||||
* [externalwarnings](externalwarnings.md)
|
||||
* [includedirs](includedirs.md)
|
40
website/docs/externalwarnings.md
Normal file
40
website/docs/externalwarnings.md
Normal file
@ -0,0 +1,40 @@
|
||||
Controls the level of warnings that are shown by the compiler for headers that are considered external.
|
||||
|
||||
```lua
|
||||
externalwarnings "value"
|
||||
```
|
||||
|
||||
If no value is set for a configuration, the toolset's default warning level will be used.
|
||||
|
||||
### Parameters ###
|
||||
|
||||
`value` specifies the desired level of warning:
|
||||
|
||||
| Value | Description |
|
||||
|-------------|--------------------------------------------------------|
|
||||
| Off | Do not show any warning messages. |
|
||||
| Default | Use the toolset's default warning level. |
|
||||
| Extra | Enable the toolset's maximum warning level. |
|
||||
| High | Enable the toolset's maximum warning level. |
|
||||
| Everything | Enable the toolset's maximum warning level. |
|
||||
|
||||
### Applies To ###
|
||||
|
||||
Project configurations.
|
||||
|
||||
### Availability ###
|
||||
|
||||
Premake 5.0 or later.
|
||||
Visual Studio 2022 version 17.0 or later.
|
||||
|
||||
### Examples ###
|
||||
|
||||
```lua
|
||||
externalwarnings "Off"
|
||||
```
|
||||
|
||||
### See Also ###
|
||||
|
||||
* [externalanglebrackets](externalanglebrackets.md)
|
||||
* [externalincludedirs](externalincludedirs.md)
|
||||
* [warnings](warnings.md)
|
@ -1,12 +1,10 @@
|
||||
Specifies the system include file search paths.
|
||||
Alias of [externalincludedirs](externalincludedirs.md).
|
||||
|
||||
```lua
|
||||
sysincludedirs { "paths" }
|
||||
```
|
||||
|
||||
For Visual Studio, these paths are placed in the "VC++ Directories" properties panel. For GCC and Clang, they are preceded with the `-isystem` flag, rather than `-I`. For toolsets which do not support the concept of system include directories, they are treated as a normal include directory.
|
||||
|
||||
Include files located via a system include directory are treated as correct: no warnings will be shown for the contents of the file.
|
||||
**This function has been deprecated in Premake 5.0 beta2.** Use the new [externalincludedirs](externalincludedirs.md) function instead. `sysincludedirs` will be not supported in Premake 6.
|
||||
|
||||
### Parameters ###
|
||||
|
||||
@ -36,5 +34,4 @@ sysincludedirs { "../includes/**" }
|
||||
|
||||
### See Also ###
|
||||
|
||||
* [includedirs](includedirs.md)
|
||||
* [syslibdirs](syslibdirs.md)
|
||||
* [externalincludedirs](externalincludedirs.md)
|
||||
|
@ -34,5 +34,6 @@ syslibdirs { "../libs/**" }
|
||||
|
||||
### See Also ###
|
||||
|
||||
* [externalincludedirs](externalincludedirs.md)
|
||||
* [libdirs](libdirs.md)
|
||||
* [sysincludedirs](sysincludedirs.md)
|
||||
|
@ -1,4 +1,4 @@
|
||||
Controls the number of warnings that are shown by the compiler.
|
||||
Controls the level of warnings that are shown by the compiler.
|
||||
|
||||
```lua
|
||||
warnings "value"
|
||||
|
@ -142,8 +142,11 @@ module.exports = {
|
||||
'entrypoint',
|
||||
'exceptionhandling',
|
||||
'external',
|
||||
'externalanglebrackets',
|
||||
'externalincludedirs',
|
||||
'externalproject',
|
||||
'externalrule',
|
||||
'externalwarnings',
|
||||
'fastuptodate',
|
||||
'fatalwarnings',
|
||||
'fileextension',
|
||||
|
Reference in New Issue
Block a user