use try_compile() instead of custom execute_process

The previous setup made a number of assumptions, e.g., on the
compiler executable name, which made the setup fail
unnecessarily in many cases.
This commit removes much of the custom code and resides to
CMake's own functionality.

Fixes bug #9 and bug #12.