diff --git a/mesonbuild/modules/external_project.py b/mesonbuild/modules/external_project.py index 572aba8a08ec..8e675bacc7f1 100644 --- a/mesonbuild/modules/external_project.py +++ b/mesonbuild/modules/external_project.py @@ -116,17 +116,19 @@ def _configure(self, state: 'ModuleState') -> None: configure_path = Path(self.src_dir, self.configure_command) configure_prog = state.find_program(configure_path.as_posix()) configure_cmd = configure_prog.get_command() - # On Windows the configure command should be converted to - # unix style path by cygpath command, + # On Cygwin, MSYS2 and GitBash the configure command should be + # converted to unix style path by cygpath command, # because the colon in the drive letter breaks many configure scripts. + # Do nothing on other environment where cygpath is not available. if ( configure_path.drive and len(configure_cmd) >= 2 and configure_cmd[-1] == configure_path.as_posix() ): - cygpath = state.find_program('cygpath').get_command() - _p, o, _e = Popen_safe(cygpath + [configure_cmd[-1]]) - configure_cmd = configure_cmd[:-1] + [Path(o.strip("\n")).as_posix()] + cygpath = state.find_program('cygpath', required=False) + if cygpath.found(): + _p, o, _e = Popen_safe(cygpath.get_command() + [configure_cmd[-1]]) + configure_cmd = configure_cmd[:-1] + [Path(o.strip("\n")).as_posix()] workdir = self.build_dir self.make = state.find_program('make').get_command()