Skip to content

Commit 3cc43da

Browse files
memshardedczoido
andauthored
new mingw example (#3717)
* new mingw example * Update examples/dev_flow/tool_requires/mingw.rst --------- Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
1 parent 79382d4 commit 3cc43da

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

examples/dev_flow.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Developer tools and flows
88

99
dev_flow/debug/step_into_dependencies
1010
dev_flow/debug/debugging_visual
11+
dev_flow/tool_requires/mingw
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. _examples_dev_flow_tool_requires_mingw:
2+
3+
Using a MinGW as tool_requires to build with gcc in Windows
4+
-----------------------------------------------------------
5+
6+
If we had MinGW installed in our environment, we could define a profile like:
7+
8+
.. code-block::
9+
10+
[settings]
11+
os=Windows
12+
compiler=gcc
13+
compiler.version=12
14+
compiler.libcxx=libstdc++11
15+
compiler.threads=posix
16+
compiler.exception=sjlj
17+
arch=x86_64
18+
build_type=Release
19+
20+
[buildenv]
21+
PATH+=(path)C:/path/to/mingw/bin
22+
# other environment we might need like
23+
CXX=C:/path/to/mingw/bin/g++
24+
# etc
25+
26+
[conf]
27+
# some configuration like 'tools.build:compiler_executables' might be needed for some cases
28+
29+
30+
But we can also use a Conan package that contains a copy of the MinGW compiler and use it
31+
as a ``tool_requires`` instead:
32+
33+
.. code-block::
34+
:caption: mingw-profile.txt
35+
36+
[settings]
37+
os=Windows
38+
compiler=gcc
39+
compiler.version=12
40+
compiler.libcxx=libstdc++11
41+
compiler.threads=posix
42+
compiler.exception=seh
43+
arch=x86_64
44+
build_type=Release
45+
46+
47+
[tool_requires]
48+
mingw-builds/12.2.0
49+
50+
51+
With this profile we can for example create a package in Windows with:
52+
53+
54+
.. code-block:: bash
55+
56+
# Using a basic template project
57+
$ conan new cmake_lib -d name=mypkg -d version=0.1
58+
$ conan create . -pr=mingw
59+
...
60+
-- The CXX compiler identification is GNU 12.2.0
61+
...
62+
63+
64+
======== Testing the package: Executing test ========
65+
mypkg/0.1 (test package): Running test()
66+
mypkg/0.1 (test package): RUN: .\example
67+
mypkg/0.1: Hello World Release!
68+
mypkg/0.1: _M_X64 defined
69+
mypkg/0.1: __x86_64__ defined
70+
mypkg/0.1: _GLIBCXX_USE_CXX11_ABI 1
71+
mypkg/0.1: MSVC runtime: MultiThreadedDLL
72+
mypkg/0.1: __cplusplus201703
73+
mypkg/0.1: __GNUC__12
74+
mypkg/0.1: __GNUC_MINOR__2
75+
mypkg/0.1: __MINGW32__1
76+
mypkg/0.1: __MINGW64__1
77+
mypkg/0.1 test_package
78+
79+
80+
.. seealso::
81+
82+
- The ConanCenter web page for the `mingw-builds package <https://conan.io/center/recipes/mingw-builds>`_
83+
- The ``conan-center-index`` `mingw-builds Github repo recipe <https://github.com/conan-io/conan-center-index/tree/master/recipes/mingw-builds/all>`_

tutorial/consuming_packages/use_tools_as_conan_packages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,6 @@ the environment activation:
239239
- :ref:`Using [system_tools] in your profiles <reference_config_files_profiles_system_tools>`.
240240
- :ref:`Creating recipes for tool_requires: packaging build tools <tutorial_other_tool_requires_packages>`.
241241
- :ref:`examples_graph_tool_requires_protobuf`
242-
- Using MinGW as tool_requires
242+
- :ref:`examples_dev_flow_tool_requires_mingw`
243243
- :ref:`Using tool_requires in profiles <reference_config_files_profile_patterns>`
244244
- Using conf to set a toolchain from a tool requires

0 commit comments

Comments
 (0)