I have a project setup that has multiple sub-projects all with their own make files. There is a master make file in the main directory that cd's into each project and runs make in the proper order.
The makefile command looks like this:
sub-project/sub-project.a:
cd sub-project ; make
The problem I have is that when I run make in vim and an error is reported, vim tries to open the file based on the relative path from inside whatever project had the error. Is there any way to have vim get the relative path from the root directory instead of the sub-project directory?
Make sure your makefile is reporting when it enters and leaves the subdirectories, as follows:
make[1]: Entering directory `/home/username/projects/projectname/subdir1'
[... compile commands ...]
make[1]: Leaving directory `/home/username/projects/projectname/subdir1'
In my experience, vim will parse this portion of the output to find the correct paths for the files with errors. Also in my (frustrated) experience as of a few years ago, without the messages vim has no idea where to look for the files referenced by the error messages.
Note that this works even with recursive subdirectory building, as in this example:
make[1]: Entering directory `/home/username/projects/projectname/subdir1'
make[2]: Entering directory `/home/username/projects/projectname/subdir1/blah'
[... compile commands ...]
make[2]: Leaving directory `/home/username/projects/projectname/subdir1/blah'
make[1]: Leaving directory `/home/username/projects/projectname/subdir1'
:make -w
is good enough to generate the directory listing that is important for vim to understand the current directory being compiled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With