Fixes PreventInSourceBuilds.cmake to work with add_subdirectory (#1383)

Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>