FindGLUT: Use pkg-config for finding dependencies
FindGLUT fails to properly link a static libglut as it does not list the dependencies needed. Use the pkg-config file if available.
I'm not sure if this is recommended as it's pulling another module along with cached variables etc. that I'm not sure would be considered a desirable behavior, and imo, the code here looks a bit ugly.
I have patched a local version of cmake to test, and it works for that, but I'm not sure what would be a good way to go about making a test for this to make sure it doesn't break for normal usage.
As another note, I have similar patches for some other Find.cmake files, particularly png, jpeg, and tiff as they sometimes have some static dependencies that do not get picked up, so I sometimes have to work around that by injecting LDFLAGS+=" $($PKG_CONFIG --libs png jpeg libtiff-4)" cmake ...
whenever a project uses libtiff or some other.
Fixes: #21924
Topic-rename: FindGLUT-pkg-config