<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:DengXian;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="ZH-CN" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi Scott, </span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks for the reply. It worked. </span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Hao. </span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b><span lang="EN-US">From: </span>
</b><span lang="EN-US"><a href="mailto:craig.scott@crascit.com">Craig Scott</a><br>
<b>Sent: </b>2017</span>年<span lang="EN-US">12</span>月<span lang="EN-US">27</span>日<span lang="EN-US"> 21:35<br>
<b>To: </b><a href="mailto:drakedog2008@outlook.com">LightGoLeft</a><br>
<b>Cc: </b><a href="mailto:cmake@cmake.org">CMake</a><br>
<b>Subject: </b>Re: [CMake] CMAKE_SIZEOF_VOID_P did not set correctly by TDM-GCC -m32 argument</span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">On Wed, Dec 27, 2017 at 7:04 PM, LightGoLeft <<a href="mailto:drakedog2008@outlook.com" target="_blank">drakedog2008@outlook.com</a>> wrote:</span></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><span lang="EN-US">Hello,<br>
<br>
I am currently using TDM-GCC-64 (MinGW) and MSVC to build binaries on 64 bit<br>
Windows to build both 32 and 64bit binaries. However, I found architecture<br>
passed to GNUtoMS bat is determined by CMAKE_SIZEOF_VOID_P which is not<br>
correctly set.<br>
<br>
For GCC, I set<br>
SET(CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}")<br>
SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")<br>
But, message(${CMAKE_SIZEOF_VOID_P }) is always 8. That causes GNUtoMS<br>
generating x64 *.lib from x86 *.a. I don't know whether this is a bug or by<br>
design.</span></p>
</blockquote>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">CMake determines the bitness of the target when it does its compiler checks, which is performed at the first project() command it hits, and it caches the result for all subsequent CMake invocations. If you need to pass
a flag like -m32 to build for 32-bit targets on a 64-bit host, you need to use a toolchain file and specify the -m32 option in there. If you simply add lines like your example above to your project's CMakeLists.txt file, they won't be picked up properly when
CMake does its compiler tests. The correct way to specify this sort of flag in a toolchain file would look something like this (note the use of ..._INIT variables):</span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">set(CMAKE_C_FLAGS_INIT -m32)</span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">set(CMAKE_CXX_FLAGS_INIT -m32)</span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">set(CMAKE_EXE_LINKER_FLAGS_INIT -m32)</span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">set(CMAKE_MODULE_LINKER_FLAGS_INIT -m32)</span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">set(CMAKE_SHARED_LINKER_FLAGS_INIT -m32)</span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Your toolchain file should also be setting CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_VERSION and CMAKE_SYSTEM_PROCESSOR to whatever is appropriate for your target architecture/platform (sorry, I'm not sure off the top of my head
what these would typically be for your case). Be sure to clear any previous build if you want to experiment with this, since CMake caches its results after the first run.</span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US">-- </span></p>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Craig Scott</span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">Melbourne, Australia</span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><a href="https://crascit.com" target="_blank">https://crascit.com</a></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p> </o:p></span></p>
</div>
</body>
</html>