cmake: Fix version determination: run git from sources directory

If build directory is outside of the sources directory then
the version of product will be determined.
Merge pull request #606 from galanthus/fix_cmake_git

cmake: Fix version determination: run git from sources directory