CMake: Add C++11 flags for XCode.
Bugfix: Use lazy initialization in factories to prevent "static initialization order" problems.
Merge branch 'compile-issues' into master.