Hey CMake Developers,

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.

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.

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:
LNK1112: module machine type 'IA64' conflicts with target machine type 'x64'

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.

https://github.com/jakepetroules/CMakeTargetArch

Thanks!

Jake Petroules
Petroules Corporation (www.petroules.com)
Email: jake.petrou...@petroules.com
Telephone: +1 (970) 587-3821

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to