Open Scylardor opened 7 years ago
This took a bit to figure out, so this is due to a very subtle feature. objdir
is more of a "base" than the actual directory, by default it will add /%{cfg.platform}/%{cfg.buildcfg}/%{prj.name}
to the end of the specified directory. You can read more about this here, the quick fix is to simply prepend your objdir
with !
: objdir "!TestApp/Build/"
.
To extend on to this further, the reason this fails is that your "objdir" becomes TestApp/Build/Linux_Static/Debug/UnitTests
for the UnitTests project, the output file of this project is called UnitTests
and is output to TestApp/Build/Linux_Static/Debug
. This then becomes the same path, but the "objdir" already exists, so the linking stage fails with the beautifully cryptic message.
It's been two days I'm puzzled with a C++ project I can't get working with Premake on Ubuntu using Makefiles. It's working just fine on other toolsets/OS like Visual Studio on Windows.
The workspace is composed of a library and a console app linking against it. I have written a set of configurations and platforms that allows me to build the lib in a static or dynamic way, combined with a debug level (debug, release, full optim.). The target and object directories are derived from the selected config / platform pair, and that seems to be a problem. I define
targetdir "TestApp/Build/%{cfg.platform}/%{cfg.buildcfg}"
andobjdir "TestApp/Build/"
in the workspace (thus they're the same for all projects, except projects intelligently put their own object files in their own folder).I managed to reproduce the issue on a very simple sample project, here's the tree structure:
So the UnitTests are linking against the Core library, but when comes the time of building the UnitTests project, it fails with an error I don't understand (I use gcc):
In fact, I found a workaround : I just need to specify a different
objdir
for the UnitTests project in the Premake script to make all of this work like a charm. But I don't understand why I need to do it.And as this project is perfectly working with other toolsets, could it be a problem with how Premake generates makefiles?
I attached a zip containing this entire sample project structure. The premake script is at the root of it. To reproduce:
(Optional)
Please take a look. Thanks!
testBreaking.zip
PS: some more info on the system: