Merge "Avoid using undefined CMake variables" into release-4-6