Fixed Platform Detect code in CMakefiles