Fix bug when constructing the full path for intermediate files generated when compiling a source file where the wrong directory could be used