CMake: Modified foreach() loop to be compatible with CMake 2.6.