[CMake] Operating system decisions

Alexander Neundorf a.neundorf-work at gmx.net
Thu Aug 6 16:24:10 EDT 2009


On Thursday 06 August 2009, Tyler Roscoe wrote:
> On Thu, Aug 06, 2009 at 12:42:44PM -0700, ML wrote:
> > Thanks Tyler, is this avail in 2.6 (WINDOWS rather than using WIN32)
> > or in a future release?
>
> It's available if you are working with CMake at my company :). Otherwise
> you can do it yourself easily:
>
>     # We want to use WINDOWS instead of the CMake-provided variable
>     # WIN32 to prevent confusion about whether WIN32 applies to 64-bit
>     # Windows (it does, but that's not obvious).
>     if (WIN32)
>         set (WINDOWS ${WIN32})
>     endif ()
>
> I mentioned it because I was sort of passively hoping that one of the
> CMake devs would see it and say, "hey, that's a good idea," and
> eventually include it in CMake proper. Until then, I have my
> CommonIncludes.cmake :).

You can also test CMAKE_SYSTEM_NAME:

if(${CMAKE_SYSTEM_NAME MATCHES} Windows)
...

etc.

Alex


More information about the CMake mailing list