cmCoreTryCompile: Move target type selection logic to try_compile This is specific to `try_compile` since `try_run` always needs an executable. Move the logic out of the common code path.