[bug fix] Fix pthread linking order for gflags for CMake

This patch is the equivalent to #1179 for CMake.

This patch resolves an error with linking to the static gflags library under Ubuntu 14.04.
The linking otherwise fails with an undefined reference to symbol 'pthread_rwlock_wrlock@@GLIBC_2.2.5'
error.