cmake: Fix the use of some cache variables

Change-Id: I2986f06b4bbe6abb154ae70d05ae23ea64ada289