BuildExecutable: use correct executable extension, build dynamically instead of statically when possible