Check if the header files exists first, then check the other conditions. Also check which cmake version we are using. The sub-command GENERATE is only availbale in v3.0.0. We need to use RENAME for the 2.8.0.