cmake: Fix version determination: run git from sources directory

If a build directory is outside of the sources directory then the version of product will be determined correctly.