premake / premake/premake-core
gmake: Makefile overriding recipe and cannot find dependency file
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 654
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 13
Description
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}" and objdir "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:
testBreaking
├── premake5.lua
└── TestApp
├── Build
│ ├── Linux_DLL
│ │ └── Debug
│ │ ├── libTestCore.so
│ │ └── TestCore
│ │ ├── core.d
│ │ └── core.o
│ └── Linux_Static
│ └── Debug
│ ├── libTestCore.a
│ └── TestCore
│ ├── core.d
│ └── core.o
├── Core
│ ├── core.cpp
│ ├── core.h
│ └── Makefile
├── Makefile
├── Tests
│ ├── Makefile
│ └── UnitTests
│ └── test.cpp
└── ThirdParty
└── Catch
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):
pando@pando-VirtualBox:~/Projects/testBreaking/TestApp$ make config=debug_linux_static
==== Building TestCore (debug_linux_static) ====
Creating ../Build/Linux_Static/Debug/TestCore
core.cpp
Linking TestCore
==== Building UnitTests (debug_linux_static) ====
Makefile:582: warning: overriding recipe for target '../Build/Linux_Static/Debug/UnitTests'
Makefile:569: warning: ignoring old recipe for target '../Build/Linux_Static/Debug/UnitTests'
test.cpp
UnitTests/test.cpp:14:1: fatal error: opening dependency file ../Build/Linux_Static/Debug/UnitTests/test.d: No such file or directory
}
^
compilation terminated.
Makefile:613: recipe for target '../Build/Linux_Static/Debug/UnitTests/test.o' failed
make[1]: *** [../Build/Linux_Static/Debug/UnitTests/test.o] Error 1
Makefile:106: recipe for target 'UnitTests' failed
make: *** [UnitTests] Error 2
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:
- premake5 gmake
- cd TestApp
- make config=debug_linux_static
(or any other config really) - Core compiles fine, but UnitTests fails
(Optional)
5. Uncomment the additional objdir in the UnitTests project in Premake script
6. Try again and observe this time it works properly
Please take a look. Thanks!
PS: some more info on the system:
uname -rvs
Linux 4.10.0-27-generic #30~16.04.2-Ubuntu SMP Thu Jun 29 16:07:46 UTC 2017
make --version
GNU Make 4.1
gcc -v
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
premake5 --version
premake5 (Premake Build Script Generator) 5.0.0-alpha11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached sample and its root premake5.lua, run premake5 gmake, then cd TestApp and run make config=debug_linux_static. Inspect the generated Makefiles around the reported targets and compare the failing shared objdir setup with the working per-project objdir workaround; done means UnitTests builds without the overriding-recipe warning or missing dependency-file error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100