diff --git a/reference/tools/gnu.rst b/reference/tools/gnu.rst index 48e2e93734b..b3f915772ff 100644 --- a/reference/tools/gnu.rst +++ b/reference/tools/gnu.rst @@ -12,3 +12,4 @@ conan.tools.gnu gnu/makedeps gnu/pkgconfigdeps gnu/pkgconfig + gnu/mingw diff --git a/reference/tools/gnu/mingw.rst b/reference/tools/gnu/mingw.rst new file mode 100644 index 00000000000..2caca1f5fc4 --- /dev/null +++ b/reference/tools/gnu/mingw.rst @@ -0,0 +1,39 @@ +.. _conan_tools_gnu_mingw: + +is_mingw +======== + +.. currentmodule:: conan.tools.gnu + +.. autofunction:: is_mingw + +The helper detects a MinGW toolchain from the recipe settings: + +* ``os`` is ``"Windows"``; +* ``os.subsystem`` is **not** ``"cygwin"`` (Cygwin uses a POSIX layer + rather than a MinGW runtime); +* ``compiler`` is ``"gcc"``, **or** it is ``"clang"`` with no + ``compiler.runtime`` set. ``clang-cl`` declares ``compiler.runtime`` + and is therefore not classified as MinGW; see the + `Different flavors of Clang on Windows + `_ + blog post for the rationale. + +Pass ``build_context=True`` to inspect ``settings_build`` instead of the +host settings (mirrors :ref:`is_msvc `). + +Example: + +.. code-block:: python + + from conan import ConanFile + from conan.tools.gnu import is_mingw + + class Pkg(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def generate(self): + if is_mingw(self): + # MinGW-specific branch: Autotools-style build, MinGW + # import-library naming, etc. + ...