The existing homebrew dependency was what inspired me to see if this was possible. :) Although it was pretty tricky and I think it was only with luck that it could be done at all. It would probably be cleanest to modify the build system so the hacks aren't needed.
I tried to submit the formula to homebrew (hope you don't mind-- I did it just before opening this thread-- although maybe I could have stopped by here first :) and they said they would prefer if the build were supported more natively. I guess I can see why, although that means more work.
https://github.com/Homebrew/homebrew/pull/34700You have my complete permission to steal the formula and do as you like :). It works for both 0.8.5 and HEAD as is.
Right now it exploits the fact that ext/gosu/extconf.rb knows how to compile for Mac. Maybe using CocoaPods would have been better, but I wasn't able to figure out how to use that for a homebrew formula. In terms of getting a good build for homebrew, though, my first thoughts are to patch cmake to support Mac builds. What do you think?
Also, although I know literally nothing about gems, I wonder if it would be possible to move the extconf.rb's logic into cmake. Then there would be one less build system to worry about.