Use cmake_{push,pop}_check_state instead of manually resetting

Authored by heikobecker on May 4 2018, 9:20 PM.