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

Doug douglas.linder at gmail.com
Wed Sep 19 11:10:06 EDT 2012


Perhaps use check_c_source_compiles?

## Check for specific apple platforms
macro(check_apple_platform)
  if(APPLE)
    include(CheckCSourceCompiles)
    check_c_source_compiles("
      #include \"TargetConditionals.h\"
      int main(int argc, char *argv[]) {
      #if !TARGET_OS_MAC
        -1
      #endif
      }
    " OS_OSX)
    check_c_source_compiles("
      #include \"TargetConditionals.h\"
      int main(int argc, char *argv[]) {
      #if !TARGET_OS_IPHONE
        -1
      #endif
      }
    " OS_IPHONE)
  endif()
endmacro()

check_apple_platform()
if(OS_OSX)
  message("Found OSX")
else()
  message("Found no OSX")
endif()
if(OS_IPHONE)
  message("Found IPHONE")
else()
  message("Found no IPHONE")
endif()

~
Doug.

On Wed, Sep 19, 2012 at 4:52 AM, Eric Wing <ewmailing at gmail.com> wrote:
> On 9/18/12, Stefan Reuschl <stefan.reuschl at gmail.com> wrote:
>> How do you crosscompile for iOS?
>> If using a CMake toolchain you could simply set a variable in that file, I
>> which you could check later...
>
> Right now I'm not brave enough to try using CMake for iOS and Android.
> I maintain separate projects. But someday I would like to do away with
> that.
>
> -Eric
> --
> Beginning iPhone Games Development
> http://playcontrol.net/iphonegamebook/
> --
>
> 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


More information about the CMake mailing list