Fix use of cmake internal variables and case sensitivity