The problem was that CMake generated a very long string with several paths and these paths, as I understand it, were passed to the PrepareForDirectorySync method. Due to the very large length of the string, the PrepareForDirectorySync method returned an error and stopped the build.