diff --git a/conan/tools/gnu/__init__.py b/conan/tools/gnu/__init__.py index a7c75b32404..bd515ad6128 100644 --- a/conan/tools/gnu/__init__.py +++ b/conan/tools/gnu/__init__.py @@ -1,5 +1,6 @@ from conan.tools.gnu.autotools import Autotools from conan.tools.gnu.autotoolstoolchain import AutotoolsToolchain from conan.tools.gnu.autotoolsdeps import AutotoolsDeps +from conan.tools.gnu.mingw import is_mingw from conan.tools.gnu.pkgconfig import PkgConfig from conan.tools.gnu.pkgconfigdeps import PkgConfigDeps diff --git a/conan/tools/gnu/mingw.py b/conan/tools/gnu/mingw.py new file mode 100644 index 00000000000..cab3cc3fe52 --- /dev/null +++ b/conan/tools/gnu/mingw.py @@ -0,0 +1,12 @@ +def is_mingw(conanfile): + """ + Validate if current compiler in host setttings is related to MinGW + + :return: True, if the host compiler is related to MinGW, otherwise False. + """ + host_os = conanfile.settings.get_safe("os") + host_compiler = conanfile.settings.get_safe("compiler") + is_mingw_gcc = host_os == "Windows" and host_compiler == "gcc" + is_mingw_clang = host_os == "Windows" and host_compiler == "clang" and \ + not conanfile.settings.get_safe("compiler.runtime") + return is_mingw_gcc or is_mingw_clang