<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey CMake Developers,<div><br></div><div>I recently came across the need to detect the architecture of the compilation target in CMake (i.e. i386, x86_64, ppc, ia64, etc.). I was rather surprised to find that CMake apparently doesn't have a function or variable to do this, as such can be useful for things like generating filenames of distribution packages built with CPack, for example.</div><div><br></div><div>So I devised a rather creative way to exploit the C preprocessor in combination with try_run in order to do this. It even works when cross compiling (try Visual Studio Itanium!); I've tested it with every generator I had easy access to, including Windows + VS 2008 and 2010 (all variants), NMake, MSYS, OS X + Xcode and regular Unix Makefiles, and Linux with Unix Makefiles.</div><div><br></div><div>During my development I did notice one oddity unrelated to my venture - CMake will fail to configure for Itanium using Visual Studio 2010 (works fine on 2008) giving error:</div><h1 style="border: none; font-family: 'Segoe UI Semibold', 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; margin: 0px; outline: 0px; padding: 0px; clear: both; color: rgb(58, 62, 67); line-height: 31px; font-size: 1.75em; list-style-type: none; text-align: left; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><span name="subject" style="border: 0px; font-weight: inherit; font-style: inherit; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; ">LNK1112: module machine type 'IA64' conflicts with target machine type 'x64'</span></h1><div><br></div><div>Anyways, I think that detecting the target architecture is something that could benefit CMake as a whole, so I've uploaded my code to GitHub and if anyone would like to take a look at it and let me know of any potential problems they see with it, suggestions, etc., that would be really helpful. If it could eventually get into mainstream CMake that would be ideal.</div><div><br></div><div><a href="https://github.com/jakepetroules/CMakeTargetArch">https://github.com/jakepetroules/CMakeTargetArch</a></div><div><br></div><div>Thanks!</div><div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Jake Petroules</div><div>Petroules Corporation (<a href="http://www.petroules.com">www.petroules.com</a>)</div><div>Email: <a href="mailto:jake.petroules@petroules.com">jake.petroules@petroules.com</a></div><div>Telephone: +1 (970) 587-3821</div></div></span></span>
</div>
<br></div></body></html>