rearrange the cmake code