Add NoLinkObjects flag

The default behaviour is to link .obj files if a custom build command
outputs them, but there are some cases where we don't want this to
happen, such as when dealing with Wavefront .obj model files.

This commit will prevent the automatic linking of .obj files that have
this new flag.

When an obj file is outputted by a custom build command, this prevents
the linker from linking it. This is necessary, for example, when
dealing with obj model files.
This commit is contained in:
aleksijuvani 2016-11-18 17:01:40 +02:00
parent 2b887281c1
commit e47ba372c8
3 changed files with 14 additions and 3 deletions

View File

@ -478,6 +478,7 @@
"NoImplicitLink",
"NoImportLib",
"NoIncrementalLink",
"NoLinkObjects",
"NoManifest",
"NoMinimalRebuild",
"NoNativeWChar", -- DEPRECATED

View File

@ -257,10 +257,12 @@
for cfg in project.eachconfig(prj) do
local filecfg = incfg[cfg]
if filecfg then
-- if the custom build outputs an object file, add it to
-- the link step automatically to match Visual Studio
-- If the custom build outputs an object file, we
-- add it to the link step automatically to match
-- Visual Studio. This behaviour can be turned off
-- by specifying the NoLinkObjects flag.
local output = project.getrelative(prj, filecfg.buildoutputs[1])
if path.isobjectfile(output) then
if path.isobjectfile(output) and not filecfg.flags.NoLinkObjects then
table.insert(configs[cfg].objects, output)
else
table.insert(configs[cfg].customfiles, output)

View File

@ -719,6 +719,7 @@
m.excludedFromBuild,
m.buildCommands,
m.buildOutputs,
m.linkObjects,
m.buildMessage,
m.buildAdditionalInputs
}
@ -1104,6 +1105,13 @@
end
function m.linkObjects(fcfg, condition)
if fcfg.flags.NoLinkObjects then
m.element("LinkObjects", condition, 'false')
end
end
function m.characterSet(cfg)
if not vstudio.isMakefile(cfg) then
m.element("CharacterSet", nil, iif(cfg.characterset == p.MBCS, "MultiByte", "Unicode"))