Change pthread flag settings in CMake to a more generic construct