Usually fitting the filter thread is all that is required. One special exception I know about are the Sony DSC-H1/DSC-H2/DSC-H5: here the lens cap fits on the camera which has something like 55.8mm lens barrel threads. You could not mount filters there since they would interfere with the lens extending but you can screw in an extension adapter tube that has 58mm threads at its front. The lens cap also fits on the end of that tube in case you want to have it permanently mounted. When the cap is on the naked camera, it has a deep rim that will actuate a switch that causes the camera to flash a "lens cap attached" message when switching the camera on without removing lens cap.
You can use a generic 58mm lens cap on the adapter tube, and you can use a generic 55mm lens cap on the camera (and on the adapter tube if you keep an 58mm–55mm step-down ring in it by default), but in case of the 55mm cap on the bare camera, switching the camera on will push the lens against the cap, resulting either in a grating noise and the camera giving up eventually, or the cap popping out.
That's the exception I encountered: here the "native" cap is considerably more useful than a generic cap. But most cameras should be fine with a generic cap of the right filter thread size.