Skip to content

new mingw example #3717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/dev_flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Developer tools and flows

dev_flow/debug/step_into_dependencies
dev_flow/debug/debugging_visual
dev_flow/tool_requires/mingw
83 changes: 83 additions & 0 deletions examples/dev_flow/tool_requires/mingw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.. _examples_dev_flow_tool_requires_mingw:

Using a MinGW as tool_requires to build with gcc in Windows
-----------------------------------------------------------

If we had MinGW installed in our environment, we could define a profile like:

.. code-block::
[settings]
os=Windows
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.exception=sjlj
arch=x86_64
build_type=Release
[buildenv]
PATH+=(path)C:/path/to/mingw/bin
# other environment we might need like
CXX=C:/path/to/mingw/bin/g++
# etc
[conf]
# some configuration like 'tools.build:compiler_executables' might be needed for some cases
But we can also use a Conan package that contains a copy of the MinGW compiler and use it
as a ``tool_requires`` instead:

.. code-block::
:caption: mingw-profile.txt
[settings]
os=Windows
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.exception=seh
arch=x86_64
build_type=Release
[tool_requires]
mingw-builds/12.2.0
With this profile we can for example create a package in Windows with:


.. code-block:: bash
# Using a basic template project
$ conan new cmake_lib -d name=mypkg -d version=0.1
$ conan create . -pr=mingw
...
-- The CXX compiler identification is GNU 12.2.0
...
======== Testing the package: Executing test ========
mypkg/0.1 (test package): Running test()
mypkg/0.1 (test package): RUN: .\example
mypkg/0.1: Hello World Release!
mypkg/0.1: _M_X64 defined
mypkg/0.1: __x86_64__ defined
mypkg/0.1: _GLIBCXX_USE_CXX11_ABI 1
mypkg/0.1: MSVC runtime: MultiThreadedDLL
mypkg/0.1: __cplusplus201703
mypkg/0.1: __GNUC__12
mypkg/0.1: __GNUC_MINOR__2
mypkg/0.1: __MINGW32__1
mypkg/0.1: __MINGW64__1
mypkg/0.1 test_package
.. seealso::

- The ConanCenter web page for the `mingw-builds package <https://conan.io/center/recipes/mingw-builds>`_
- The ``conan-center-index`` `mingw-builds Github repo recipe <https://github.com/conan-io/conan-center-index/tree/master/recipes/mingw-builds/all>`_
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ the environment activation:
- :ref:`Using [system_tools] in your profiles <reference_config_files_profiles_system_tools>`.
- :ref:`Creating recipes for tool_requires: packaging build tools <tutorial_other_tool_requires_packages>`.
- :ref:`examples_graph_tool_requires_protobuf`
- Using MinGW as tool_requires
- :ref:`examples_dev_flow_tool_requires_mingw`
- :ref:`Using tool_requires in profiles <reference_config_files_profile_patterns>`
- Using conf to set a toolchain from a tool requires