Improve cmake check for NX detection. Patch by Andreas Pakulat.