Fix use of protobuf from build
Use different input files to generate the CMake package configuration for the build tree and the install tree. This avoids the build tree trying to refer to our installed copy of protobuf which won't exist if we haven't been installed. This does require a full copy of protobuf (as opposed to just the libraries) when we are used from the build tree, but since we needed that to build, it ought to be available.
Also, fix a small issue in how we check whether we need to use our internal copy of protobuf.