Fix a bug and use EXTRA... variables for cmake.