All perfect praise be to Allah the Lord of the Worlds. May His peace and blessings be upo
n Prophet Mohammad and upon all his family and companions.
It is conditioned that an endowment can be benefited from according to Sharia while the property itself remains. The benefit should be as deemed by the endower. The building mentioned in the above question meets these conditions, so it is permissible to endow the place that fits as mosque for women and that which fits as mosque for men and both places shall have the rulings of mosque. As for the rest of the building, it is the private property of the endower and she may dispose of it as she likes. And Allah the Almighty Knows Best.