Git version detection not working on MacOS

When building on MacOS the following appears during CMake configuration:

-- Not in a git repo

Which means the git repo doesn't get detected correctly, which results in:

Starting PeTrack
Version: 0.8.15
Commit id: UNKNOWN
Commit date: UNKNOWN
Build from branch: UNKNOWN
Compile date: Fri Mar 12 20:55:05 2021
Build with: clang++ (12.0.5)