[CMake] Get Visual Studio target Arch

Alexey Petruchik alexey.petruchik at gmail.com
Mon Sep 15 17:08:20 EDT 2014


Hi, Gilles.
First of all it is great to hear that Microsoft engineers are aware of
cmake and even maintain fork that adds more Visual Studio compatibility.
Great work!
Adding ability to generate one unified solution with multiple architecture
support is nice. It is really much better than regenerating solution for
each platform all the time.
But I dont see how this solves my original issue. Actually it even make it
worse. What I want to do is to specify different CMAKE_LIBRARY_PATH for
different target arch so when I build my project for Win32 arch I'll use
prebuilt libs from win32/libs/x86 forlder, and when I build for x64 arch -
win32/libs/x64 folder. Of course I can rename my folders so they correspond
to $(Platform) var in VS but this doesn't look like a solid solution for
me. I still cant really make some arch specific ifdefs in my cmake scripts
using this approach. In my opinion we should fix CMAKE_SYSTEM_PROCESSOR
behaviour on Windows. It doesnt look sane for me when var that should be
defined as "The name of the CPU CMake is building for." is defined as AMD64
for ARM build.
Another wish is that installer of your fork should by default install to
different dir than vanilla cmake and even have different binary names. This
will make easier side by side installation of cmakems and vanilla cmake.
Regards, Alexey

On Thu, Sep 11, 2014 at 6:36 PM, Gilles Khouzam <
Gilles.Khouzam at microsoft.com> wrote:

> Hi Greg,
>
> You might want to check out our current fork of CMake on
> http://cmakems.codeplex.com. I've just added support for multiplatform
> support for Windows Phone and Windows Store app in a similar way that it is
> done for iOS.
>
> You can try the build on http://cmakems.codeplex.com/releases/view/132284
> or use the MSMultiPlatform branch. This will generate one solution that can
> target Win32/ARM/x64 placing each architecture in a folder based on the
> platform name (using the $(Platform) variable in VS.
>
> To enable this, add the following define:
> CMAKE_VS_EFFECTIVE_PLATFORMS=Win32;ARM;x64 and code for all three platforms
> will be generated. We'd love to understand the type of issues you might run
> into with this and how we can make it better.
>
> Thanks
> ~Gilles
>
> -----Original Message-----
> From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Gregor Jasny
> Sent: Monday, September 8, 2014 12:06
> To: cmake at cmake.org; Alexey Petruchik
> Subject: Re: [CMake] Get Visual Studio target Arch
>
> On 06/09/14 16:02, Alexey Petruchik wrote:
> > I want to use different library folders for x64/x86/arm architectures.
> > Cmake has different generators for each arch: "Visual Studio 12 2013",
> > "Visual Studio 12 2013 ARM", "Visual Studio 12 2013 Win64". Is there
> > any cmake var to get visual studio target arch? CMAKE_SYSTEM_PROCESSOR
> > is always AMD64 for me no matter what generator I'm using.
>
> All the already available stuff in cmake is not sufficient. Especially if
> you start to cross compile.
>
> I use the pre-defined C/C++ preprocessor symbols for that:
>
> include(CheckSymbolExists)
>
> if(WIN32)
>   check_symbol_exists("_M_AMD64" "" RTC_ARCH_X64)
>   if(NOT RTC_ARCH_X64)
>     check_symbol_exists("_M_IX86" "" RTC_ARCH_X86)
>   endif(NOT RTC_ARCH_X64)
>   # add check for arm here
>   # see http://msdn.microsoft.com/en-us/library/b0084kay.aspx
> else(WIN32)
>   check_symbol_exists("__i386__" "" RTC_ARCH_X86)
>   check_symbol_exists("__x86_64__" "" RTC_ARCH_X64)
>   check_symbol_exists("__arm__" "" RTC_ARCH_ARM)
> endif(WIN32)
>
> Now you could write:
>
> if(RTC_ARCH_X64)
>   set(MY_LIB_DIR x64)
> elseif(RTC_ARCH_X86)
>   set(MY_LIB_DIR x86)
> elseif(RTC_ARCH_ARM)
>   set(MY_LIB_DIR x86)
> else()
>   message(FATAL_ERROR "Unknown architecture")
> endif()
>
> I hope this helps.
>
> Thanks,
> Gregor
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140916/6a049ca1/attachment.html>


More information about the CMake mailing list