Skip to content

Commit

Permalink
Merge branch 'mcallet/fix-makefile-export' into 'main'
Browse files Browse the repository at this point in the history
fix: check [Export] flag on makefile generation to avoid LDDEPS declaration

See merge request Sharpmake/sharpmake!482
  • Loading branch information
jspelletier committed Jan 19, 2024
2 parents d66f04a + c2099cb commit 683f614
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Sharpmake.Generators/Generic/Makefile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File
var deps = new OrderableStrings();
foreach (Project.Configuration depConf in conf.ResolvedDependencies)
{
// Ignore projects marked as Export
if (depConf.Project.SharpmakeProjectType == Project.ProjectTypeAttribute.Export)
continue;

switch (depConf.Output)
{
case Project.Configuration.OutputType.None:
Expand Down
1 change: 1 addition & 0 deletions samples/HelloLinux/codebase/exe/exe.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public override void ConfigureAll(Configuration conf, CommonTarget target)
conf.AddPrivateDependency<Dll1Project>(target);
conf.AddPrivateDependency<StaticLib2Project>(target);
conf.AddPrivateDependency<HeaderOnlyLibProject>(target);
conf.AddPrivateDependency<ExternalLibProject>(target);

conf.Defines.Add("CREATION_DATE=\"October 2020\"");
}
Expand Down
34 changes: 34 additions & 0 deletions samples/HelloLinux/codebase/external_lib/external_lib.sharpmake.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Ubisoft. All Rights Reserved.
// Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license information.

using System.IO;
using System;
using Sharpmake;
using System.Linq;

namespace HelloLinux
{
[Export]
//This export keyword will:
// 1 - Prevent the generation of a dedicated makefile for this project
// 2 - Prevent the inclusion of this project into the LDDEPS list of your makefile
// In this example only the configured projectName will be added into the LDLIBS flag in the generated makefile.
public class ExternalLibProject : CommonProject
{
public ExternalLibProject()
{
AddTargets(CommonTarget.GetDefaultTargets());

//We name this project voluntarly curl in order to link to a library already existing in this OS.
Name = "curl";
}

public override void ConfigureAll(Configuration conf, CommonTarget target)
{
base.ConfigureAll(conf, target);

//We use the static library format because it's the one already existing inside the OS.
conf.Output = Configuration.OutputType.Lib;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ifeq ($(config),debug)
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
CFLAGS += $(CPPFLAGS) -g -Wall
CXXFLAGS += $(CFLAGS) -fno-exceptions -fno-rtti
LDFLAGS += -L../../bin/linux_debug -L../../lib/linux_debug/static\ lib2 -Wl,-rpath='$$ORIGIN'
LDLIBS += -l:libdll1.so -l:libstatic\ lib2.a -l:libuuid.so
LDFLAGS += -L../../bin/linux_debug -L../../lib/linux_debug/curl -L../../lib/linux_debug/static\ lib2 -Wl,-rpath='$$ORIGIN'
LDLIBS += -l:libcurl.a -l:libdll1.so -l:libstatic\ lib2.a -l:libuuid.so
RESFLAGS += $(DEFINES) $(INCLUDES)
LDDEPS += ../../bin/linux_debug/libdll1.so ../../lib/linux_debug/static\ lib2/libstatic\ lib2.a ../../lib/linux_debug/static_lib1/libstatic_lib1.a
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(LDLIBS)
Expand Down Expand Up @@ -51,8 +51,8 @@ ifeq ($(config),release)
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
CFLAGS += $(CPPFLAGS) -g -O3 -Wall
CXXFLAGS += $(CFLAGS) -fno-exceptions -fno-rtti
LDFLAGS += -L../../bin/linux_release -L../../lib/linux_release/static\ lib2 -Wl,-rpath='$$ORIGIN'
LDLIBS += -l:libdll1.so -l:libstatic\ lib2.a -l:libuuid.so
LDFLAGS += -L../../bin/linux_release -L../../lib/linux_release/curl -L../../lib/linux_release/static\ lib2 -Wl,-rpath='$$ORIGIN'
LDLIBS += -l:libcurl.a -l:libdll1.so -l:libstatic\ lib2.a -l:libuuid.so
RESFLAGS += $(DEFINES) $(INCLUDES)
LDDEPS += ../../bin/linux_release/libdll1.so ../../lib/linux_release/static\ lib2/libstatic\ lib2.a ../../lib/linux_release/static_lib1/libstatic_lib1.a
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(LDLIBS)
Expand Down

0 comments on commit 683f614

Please sign in to comment.