Fix out of source builds

Fixes #1018