Browse Source

CMake: Tweaks to distinguish iOS and macOS.

Donny Lawrence 6 years ago
parent
commit
aa776e4278

+ 28 - 9
dtool/Config.cmake

@@ -18,6 +18,9 @@ endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
   set(IS_OSX 1)
 endif()
+if(CMAKE_SYSTEM_NAME MATCHES "iOS")
+  set(IS_IOS 1)
+endif()
 if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
   set(IS_FREEBSD 1)
 endif()
@@ -386,15 +389,31 @@ mark_as_advanced(DO_MEMORY_USAGE SIMULATE_NETWORK_DELAY
 # This section relates to mobile-device/phone support and options
 #
 
-# iPhone support
-set(BUILD_IPHONE "" CACHE STRING
-  "Panda contains some experimental code to compile for IPhone.  This
-requires the Apple IPhone SDK, which is currently only available
-for OS X platforms.  Set this to either 'iPhoneSimulator' or
-'iPhoneOS'.  Note that this is still *experimental* and incomplete!
-Don't enable this unless you know what you're doing!")
-set_property(CACHE BUILD_IPHONE PROPERTY STRINGS "" iPhoneSimulator iPhoneOS)
+# iOS support
+if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
+  # Check if THIRDPARTY_DIRECTORY is defined, and warn the user if it isn't.
+  if(NOT THIRDPARTY_DIRECTORY)
+    message(WARNING "Since you're building for iOS, you'll probably want to use
+THIRDPARTY_DIRECTORY to point CMake at the correct libraries.")
+  endif()
 
+  # Add options for Simulator and Device, which will automatically set the target
+  # architecture if we're using a single config generator.
+  if(IS_MULTICONFIG)
+    # Xcode will handle what architecture we should use.
+    option(IOS_BUILD_FAT_BINARIES "When this option is selected, build binaries
+that support both Simulator and Device, no matter what platform is selected from
+within Xcode itself." ON)
+
+    if(IOS_BUILD_FAT_BINARIES)
+      set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH OFF CACHE BOOL)
+      set(CMAKE_IOS_INSTALL_COMBINED ON CACHE BOOL)
+    else()
+      set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH ON CACHE BOOL)
+      set(CMAKE_IOS_INSTALL_COMBINED OFF CACHE BOOL)
+    endif()
+  endif()
+endif()
 
 # Android support
 option(BUILD_ANDROID
@@ -504,7 +523,7 @@ else()
 endif()
 
 cmake_dependent_option(HAVE_COCOA "Enable Cocoa. Requires Mac OS X." ON
-  "APPLE" OFF)
+  "IS_OSX" OFF)
 
 #
 # Miscellaneous settings

+ 1 - 1
dtool/LocalSetup.cmake

@@ -150,7 +150,7 @@ check_cxx_compiler_flag(-msse2 HAVE_SSE2)
 # Also set the library type used for "modules" appropriately.
 if(BUILD_SHARED_LIBS)
   set(LINK_ALL_STATIC OFF)
-  if(IOS)
+  if(IS_IOS)
     set(MODULE_TYPE "SHARED"
       CACHE INTERNAL "" FORCE)
   else()

+ 3 - 3
dtool/Package.cmake

@@ -97,10 +97,10 @@ if(HAVE_PYTHON)
     endif()
   endif()
 
-  set(PYTHON_LIB_INSTALL_DIR "${_LIB_DIR}" CACHE STRING
+  set(PYTHON_LIB_INSTALL_DIR "${_LIB_DIR}" CACHE PATH
     "Path to the Python architecture-independent package directory.")
 
-  set(PYTHON_ARCH_INSTALL_DIR "${_ARCH_DIR}" CACHE STRING
+  set(PYTHON_ARCH_INSTALL_DIR "${_ARCH_DIR}" CACHE PATH
     "Path to the Python architecture-dependent package directory.")
 
   set(PYTHON_EXTENSION_SUFFIX "${_EXT_SUFFIX}" CACHE STRING
@@ -465,7 +465,7 @@ package_option(GLES1
 package_status(GLES1 "OpenGL ES 1.x")
 
 # OpenGL ES 2
-if(NOT APPLE) # Apple X11 ships the GLES headers but they're broken
+if(NOT IS_OSX) # Apple X11 ships the GLES headers but they're broken
   find_package(OpenGLES2 QUIET)
 endif()
 

+ 1 - 1
dtool/dtool_config.h.in

@@ -255,6 +255,6 @@
 #cmakedefine IS_OSX
 #cmakedefine IS_LINUX
 #cmakedefine IS_FREEBSD
-#cmakedefine BUILD_IPHONE
+#cmakedefine IS_IOS
 
 #endif

+ 5 - 1
dtool/src/dtoolutil/CMakeLists.txt

@@ -80,7 +80,11 @@ target_interrogate(p3dtoolutil ALL EXTENSIONS ${P3DTOOLUTIL_IGATEEXT})
 
 if(APPLE)
   find_library(FOUNDATION_LIBRARY Foundation)
-  find_library(APPKIT_LIBRARY AppKit)
+  if(IS_OSX)
+    find_library(APPKIT_LIBRARY AppKit)
+  else()
+    set(APPKIT_LIBRARY "")
+  endif()
   target_link_libraries(p3dtoolutil ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY})
 endif()
 

+ 1 - 1
panda/src/cocoadisplay/CMakeLists.txt

@@ -1,4 +1,4 @@
-if(NOT APPLE OR NOT HAVE_GL OR NOT HAVE_COCOA)
+if(NOT IS_OSX OR NOT HAVE_GL OR NOT HAVE_COCOA)
   return()
 endif()
 

+ 2 - 1
panda/src/device/CMakeLists.txt

@@ -63,7 +63,8 @@ target_interrogate(p3device ALL)
 if(WIN32)
   target_link_libraries(p3device Cfgmgr32.lib)
 
-elseif(APPLE)
+# IOKit is a private framework on iOS.
+elseif(IS_OSX)
   find_library(IOKIT_LIBRARY IOKit)
   target_link_libraries(p3device ${IOKIT_LIBRARY})