In an action for the recovery of real property, upon which permanent improvements have been made by a defendant or intervener, or those under whom he claims, holding under color of title adversely to claim of plaintiff, or another defendant or intervener, in good faith, the value of such improvements must be allowed as a counterclaim by such defendant or intervener.
SDCL 21-14-5