Use try_compile in test.

Ensure that the CMAKE_MAKE_PROGRAM and configuration etc are
propagated.
Merge topic 'fix-Qt4-moc-commands-depends' into next

e71dedcf Use try_compile in test.