[CMake] How to check the operating system is MacOSX?

Michael Jackson mike.jackson at bluequartz.net
Sun Sep 16 10:38:23 EDT 2012


On Sep 15, 2012, at 1:32 PM, Andreas Pakulat wrote:

> Hi,
> 
> On Sat, Sep 15, 2012 at 12:46 PM, Loaden <loaden at gmail.com> wrote:
>> http://www.cmake.org/Wiki/CMake_Useful_Variables
>> 
>>> UNIX  is TRUE on all UNIX-like OS's, including Apple OS X and CygWin WIN32
>>> is TRUE on Windows, including CygWin APPLE  is TRUE on Apple systems. Note
>>> this does not imply the system is Mac OS X, only that __APPLE__ is #defined
>>> in C/C++ header files. Obtain more specific system information via
>>> CMAKE_SYSTEM_VERSION, i.e. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin"), then
>>> it's Mac OS X.
> 
> I think that mostly refers to MacOS 9 and older which are also apple
> systems. So doing a if(UNIX && APPLE) should put you on the safe side
> since MacOS 9 and older are not unix systems.
> 
> Andreas

Does CMake even run on OS 9? I don't think so. IMO, I think what the CMake devs mean is that one can cross-compile OS X apps on Linux. In this case the __APPLE__ would be defined in the headers but the "host" system would be Linux (or something else).
  And "technically" if the system is Darwin it is NOT OS X. Darwin is the Unix underpinnings of OS X and it is Open Source. I could run a Darwin system and have it NOT be OS X. 
--
Mike Jackson <www.bluequartz.net>



More information about the CMake mailing list