diff --git a/contrib/curl/premake5.lua b/contrib/curl/premake5.lua index 5a49939d..474f5cfa 100644 --- a/contrib/curl/premake5.lua +++ b/contrib/curl/premake5.lua @@ -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" diff --git a/modules/codelite/codelite_project.lua b/modules/codelite/codelite_project.lua index 2b14f155..ea247c19 100755 --- a/modules/codelite/codelite_project.lua +++ b/modules/codelite/codelite_project.lua @@ -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, '', 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, '', project.getrelative(cfg.project, includepath)) end _p(3, '') diff --git a/modules/codelite/tests/test_codelite_config.lua b/modules/codelite/tests/test_codelite_config.lua index 9b6b49bd..84839bb5 100644 --- a/modules/codelite/tests/test_codelite_config.lua +++ b/modules/codelite/tests/test_codelite_config.lua @@ -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 [[ diff --git a/modules/gmake/gmake_cpp.lua b/modules/gmake/gmake_cpp.lua index 5fa7d168..acdf6010 100644 --- a/modules/gmake/gmake_cpp.lua +++ b/modules/gmake/gmake_cpp.lua @@ -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 diff --git a/modules/gmake2/gmake2_cpp.lua b/modules/gmake2/gmake2_cpp.lua index 682a3b3b..eb3ab96e 100644 --- a/modules/gmake2/gmake2_cpp.lua +++ b/modules/gmake2/gmake2_cpp.lua @@ -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 diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 683d4b30..516b8d15 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -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 diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua index a9f017cf..07cd658a 100644 --- a/modules/vstudio/tests/_tests.lua +++ b/modules/vstudio/tests/_tests.lua @@ -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" } diff --git a/modules/vstudio/tests/vc2010/test_nmake_props.lua b/modules/vstudio/tests/vc2010/test_nmake_props.lua index a4dafad7..bf51cf42 100644 --- a/modules/vstudio/tests/vc2010/test_nmake_props.lua +++ b/modules/vstudio/tests/vc2010/test_nmake_props.lua @@ -162,8 +162,8 @@ command 2 ]] end - function suite.onSysIncludeDirs() - sysincludedirs { "include/lua", "include/zlib" } + function suite.onExternalIncludeDirs() + externalincludedirs { "include/lua", "include/zlib" } prepare() test.capture [[ diff --git a/modules/vstudio/tests/vc2010/test_output_props.lua b/modules/vstudio/tests/vc2010/test_output_props.lua index 71fb27fa..eec855c6 100644 --- a/modules/vstudio/tests/vc2010/test_output_props.lua +++ b/modules/vstudio/tests/vc2010/test_output_props.lua @@ -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 [[ diff --git a/modules/vstudio/tests/vc2022/test_compile_settings.lua b/modules/vstudio/tests/vc2022/test_compile_settings.lua new file mode 100644 index 00000000..aa6f3244 --- /dev/null +++ b/modules/vstudio/tests/vc2022/test_compile_settings.lua @@ -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 [[ + + NotUsing + Level3 + Disabled + TurnOffAllWarnings + ]] +end + +function suite.ExternalWarningLevelDefault() + externalwarnings "Default" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Level3 + ]] +end + +function suite.ExternalWarningLevelHigh() + externalwarnings "High" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Level4 + ]] +end + +function suite.ExternalWarningLevelExtra() + externalwarnings "Extra" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Level4 + ]] +end + +function suite.ExternalWarningLevelEverything() + externalwarnings "Everything" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Level4 + ]] +end + +-- +-- Check ClCompile for TreatAngleIncludeAsExternal +-- +function suite.TreatAngleIncludeAsExternalOn() + externalanglebrackets "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Level3 + true + ]] +end + +function suite.TreatAngleIncludeAsExternalOff() + externalanglebrackets "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Level3 + false + ]] +end diff --git a/modules/vstudio/tests/vc2022/test_output_props.lua b/modules/vstudio/tests/vc2022/test_output_props.lua new file mode 100644 index 00000000..67f6aba0 --- /dev/null +++ b/modules/vstudio/tests/vc2022/test_output_props.lua @@ -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 [[ + + true + bin\Debug\ + obj\Debug\ + MyProject + .exe + src\include;$(ExternalIncludePath) + + ]] +end diff --git a/modules/vstudio/tests/vc2022/test_toolset_settings.lua b/modules/vstudio/tests/vc2022/test_toolset_settings.lua index d72bb4c7..a1494e05 100644 --- a/modules/vstudio/tests/vc2022/test_toolset_settings.lua +++ b/modules/vstudio/tests/vc2022/test_toolset_settings.lua @@ -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 -- diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index b28a2f07..7068a15f 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -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 diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index fc853a81..db163058 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -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") diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index b4373763..4dfda3ed 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -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]) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index d0cbf7cc..1625e6b9 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -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 diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 4eede91d..90ca05fc 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -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 diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 438a72e8..8961c40e 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -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 diff --git a/src/tools/msc.lua b/src/tools/msc.lua index 11fce02b..e8046070 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -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 diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index fb543506..4a5923ee 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -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" } diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 32992264..56bf1824 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -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() diff --git a/website/docs/Project-API.md b/website/docs/Project-API.md index 4ef93b28..4ca4bb4a 100644 --- a/website/docs/Project-API.md +++ b/website/docs/Project-API.md @@ -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) | | diff --git a/website/docs/Whats-New-in-5.0.md b/website/docs/Whats-New-in-5.0.md index d752fcce..8de8a6e2 100644 --- a/website/docs/Whats-New-in-5.0.md +++ b/website/docs/Whats-New-in-5.0.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) diff --git a/website/docs/externalanglebrackets.md b/website/docs/externalanglebrackets.md new file mode 100644 index 00000000..b863ca65 --- /dev/null +++ b/website/docs/externalanglebrackets.md @@ -0,0 +1,28 @@ +Treats all headers included by `#include
`, 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) diff --git a/website/docs/externalincludedirs.md b/website/docs/externalincludedirs.md new file mode 100644 index 00000000..da27c734 --- /dev/null +++ b/website/docs/externalincludedirs.md @@ -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) diff --git a/website/docs/externalwarnings.md b/website/docs/externalwarnings.md new file mode 100644 index 00000000..2811a3a7 --- /dev/null +++ b/website/docs/externalwarnings.md @@ -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) diff --git a/website/docs/sysincludedirs.md b/website/docs/sysincludedirs.md index ab05bce7..6590605b 100644 --- a/website/docs/sysincludedirs.md +++ b/website/docs/sysincludedirs.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) diff --git a/website/docs/syslibdirs.md b/website/docs/syslibdirs.md index 3bc5a333..9b8dd339 100644 --- a/website/docs/syslibdirs.md +++ b/website/docs/syslibdirs.md @@ -34,5 +34,6 @@ syslibdirs { "../libs/**" } ### See Also ### +* [externalincludedirs](externalincludedirs.md) * [libdirs](libdirs.md) * [sysincludedirs](sysincludedirs.md) diff --git a/website/docs/warnings.md b/website/docs/warnings.md index cc37adb7..ac1096e8 100644 --- a/website/docs/warnings.md +++ b/website/docs/warnings.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" diff --git a/website/sidebars.js b/website/sidebars.js index 2768e51f..b4a98322 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -142,8 +142,11 @@ module.exports = { 'entrypoint', 'exceptionhandling', 'external', + 'externalanglebrackets', + 'externalincludedirs', 'externalproject', 'externalrule', + 'externalwarnings', 'fastuptodate', 'fatalwarnings', 'fileextension',