[CMake] WIN32 vs WIN64

David Cole david.cole at kitware.com
Mon Oct 26 20:55:00 EDT 2009


On Win64, in a 32-bit calling environment, there are two environment
variables with values like this:
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_ARCHITEW6432=AMD64

In a pure 64-bit calling environment, there is just:
PROCESSOR_ARCHITECTURE=AMD64
(and no value for PROCESSOR_ARCHITEW6432)

...so: you could do something like this (although it may not be 100%
foolproof...):
if("$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "")
  if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "x86")
    # "pure" 32-bit environment...
  else()
    # "pure" 64-bit environment...
  endif()
else()
  if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "x86")
    # 32-bit program running with an underlying 64-bit environment
available...
  else()
    # theoretically impossible case...
  endif()
endif()

Of course, it would be better to not have conditionals based on the
environment... Why do you need to do this?


HTH,
David


On Mon, Oct 26, 2009 at 6:46 PM, James Bigler <jamesbigler at gmail.com> wrote:

> All the WIN32 flags say they are valid for WIN64 machines.  Is there no
> equivalent WIN64 flag to determine if the OS is 32 or 64 bit regardless of
> the bitness of the build?
>
> Thanks,
> James
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091026/5c9f8b20/attachment.htm>


More information about the CMake mailing list