Formally known as Accessory Dwelling Units (ADU), the legality [of granny flats] is dependent on local zoning ordinances and HOA rules, but the municipal code in Ft. Worth, Texas does currently allow them. See the specific Ft. Worth ordinance concerning an ADU here.
While Ft. Worth is flexible concerning an ADU and provides an allowance for it provided you meet the rules, the city of Dallas demands that an ADU is only permissible via a special exemption.
If you are considering renovating or building an ADU or mother-in-law cottage, be cautious and carefully research the local laws and limitations. Still, even in cases where local ordinances prohibit such a dwellings, an exemption may be made.