premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.17k stars 617 forks source link

links broken on MacOS #2232

Open crazydef opened 1 month ago

crazydef commented 1 month ago

What seems to be the problem? I have a workspace with multiple shared library projects and multiple applications.

As you would expect, each project has multiple configurations:

configurations
{
  "Debug",
  "Release",
  etc...
}

The output from each project has the configuration as part of the name:

targetsuffix ".%{cfg.buildcfg}"

The applications use dependson and links to setup build dependencies and linker inputs.

However, when using links as follows:

links
{
  "A",
}

Xcodebuild only ever attempts to use the Debug build of a library, regardless of the configuration actually being built.

clang: error: no such file or directory: '/Users/james/Work/KDI/Projects/Test/Release/libA.Debug.dylib'

To work around this, it is necessary to specify the entire library name in the links setting:

links
{
  "A.%{cfg.buildcfg}",
}

The documentation for links says:

When linking against another project in the same workspace, specify the project name here, rather than the library name. Premake will figure out the correct library to link against for the current configuration, and will also create a dependency between the projects to ensure a proper build order.

For Windows (vs2022) and Linux (gmake2) the above appears to be correct. However, this is not the case on MacOS.

Related to this, it appears build dependencies are also not set correctly on any platform, (I must use both links and depends) but that could be a consequence of needing to specify the full library name.

What did you expect to happen? I expected MacOS to work the same as other platforms.

How can we reproduce this? Test.zip

Unzip the attached, and run the following commands to reproduce the issue:

premake5 xcode4
xcodebuild -verbose -project X.xcodeproj -configuration Release build

What version of Premake are you using? 5.0.0-dev

crazydef commented 1 month ago

Possibly related, I also see these warnings from xcode when building:

2024-07-31 10:07:33.155 xcodebuild[99013:2054129] warning:  The file reference for "A.xcodeproj" is a member of multiple groups ("Projects" and "Projects"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
2024-07-31 10:07:33.155 xcodebuild[99013:2054129] warning:  The file reference for "B.xcodeproj" is a member of multiple groups ("Projects" and "Projects"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
2024-07-31 10:07:33.170 xcodebuild[99013:2054129] warning:  The file reference for "A.xcodeproj" is a member of multiple groups ("Projects" and "Projects"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.