<div dir="ltr">What version of CMake are you using?  If it's 3.0, then it's possible that they've gotten smarter.  I'm using 2.8, and I confirmed that even with an empty directory, CMAKE_CL_64 in GetHostTriple() is never set regardless of which toolchain is in use.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 30, 2014 at 10:22 AM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Tue, Jul 29, 2014 at 5:38 PM, Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br>
> I'm trying to figure out how to get, from CMake, the architecture of the<br>
> platform that I'm compiling LLVM for.  If I'm building LLVM on x86, I want<br>
> x86.  On x64 I want x86_64.  On arm arm.  etc.<br>
><br>
> The best I can figure out so far is that I should use LLVM_HOST_TRIPLE, and<br>
> extract the first component of this.  At least if my understanding is<br>
> correct, I should have the following behavior:<br>
><br>
> Compiling using 32-bit toolchain on Windows: LLVM_HOST_TRIPLE =<br>
> i686-pc-win32<br>
> Compiling using 64-bit toolchain on Windows: LLVM_HOST_TRIPLE =<br>
> x86_64-pc-win32<br>
><br>
> This doesn't currently seem to work.  See, for example, the following output<br>
> from when I run CMake twice from the command line, once with an x86<br>
> toolchain and once with an x64 toolchain:<br>
><br>
> D:\src\llvm\build\ninja>"c:\Program Files (x86)\Microsoft Visual Studio<br>
> 12.0\VC\vcvarsall.bat" x86<br>
><br>
> D:\src\llvm\build\ninja>where cl<br>
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe<br>
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe<br>
><br>
> D:\src\llvm\build\ninja>cmake ..\..<br>
> -- Target triple: i686-pc-win32<br>
> -- Native target architecture is X86<br>
><br>
> D:\src\llvm\build\ninja>"c:\Program Files (x86)\Microsoft Visual Studio<br>
> 12.0\VC\vcvarsall.bat" x86_amd64<br>
><br>
> D:\src\llvm\build\ninja>where cl<br>
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe<br>
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe<br>
><br>
> D:\src\llvm\build\ninja>cmake ..\..<br>
> -- Target triple: i686-pc-win32<br>
> -- Native target architecture is X86<br>
<br>
</div></div>Could this be due to CMake caching (and not updating that cache) the<br>
compiler it uses? If I run cmake in an empty directory, it seems to<br>
get the Target triple right:<br>
<br>
D:\src>mkdir build.x86 && cd build.x86<br>
D:\src\build.x86>"c:\Program Files (x86)\Microsoft Visual Studio<br>
12.0\VC\vcvarsall.bat" x86<br>
D:\src\build.x86>cmake -GNinja ..\llvm<br>
[...]<br>
<div class="">-- Target triple: i686-pc-win32<br>
-- Native target architecture is X86<br>
<br>
</div>D:\src\build.x86>cd .. && mkdir build.amd64 && cd build.amd64<br>
D:\src\build.amd64>"c:\Program Files (x86)\Microsoft Visual Studio<br>
12.0\VC\vcvarsall.bat" x86_amd64<br>
D:\src\build.amd64>cmake -GNinja ..\llvm<br>
[...]<br>
-- Target triple: x86_64-pc-win32<br>
<div class="HOEnZb"><div class="h5">-- Native target architecture is X86<br>
</div></div></blockquote></div><br></div>