Does a mortgage cosigner have to be a relative?

No, you do not have to be related. you are signing a binding contract agreeing that both of you are responsible for the payments for that mortgage loan. You will both have to provide all the information- taxes, income, debts, assets, etc.

Just be careful who you are getting yourself stuck with for 30 years. :)