Browse Source

CMake: Use dynamic symbol lookup so Python libs don't need to be present at build-time.

I think it's better to link Python into the app itself rather than in the Panda build, so set a compiler flag accordingly. Also, the python-cmake-buildsystem output target .cmake file uses a different variable name for the Python headers than the FindPython.cmake module, so check for both.
Donny Lawrence 6 years ago
parent
commit
c61084118f

+ 6 - 1
dtool/Package.cmake

@@ -33,9 +33,14 @@ find_package(Python ${WANT_PYTHON_VERSION} QUIET COMPONENTS Interpreter Developm
 if(Python_FOUND)
   set(PYTHON_FOUND ON)
   set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
-  set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS})
   set(PYTHON_VERSION_STRING ${Python_VERSION})
 
+  if(DEFINED PYTHON_INCLUDE_DIR)
+    set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
+  else()
+    set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS})
+  endif()
+
 else()
   find_package(PythonInterp ${WANT_PYTHON_VERSION} QUIET)
   find_package(PythonLibs ${PYTHON_VERSION_STRING} QUIET)

+ 7 - 0
panda/metalibs/pandagles2/CMakeLists.txt

@@ -22,6 +22,13 @@ add_metalib(pandagles2 ${MODULE_TYPE}
   COMPONENTS ${PANDAGLES2_LINK_TARGETS})
 unset(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
 
+if(CMAKE_SYSTEM_NAME STREQUAL iOS)
+  # We won't be linking with libpython until the wrapper app itself is built,
+  # so we'll quelch the errors that get spit out when trying to build with
+  # missing symbols.
+  target_link_options(pandagles2 PRIVATE -undefined dynamic_lookup)
+endif()
+
 install(TARGETS pandagles2
   EXPORT GLES COMPONENT GLES
   DESTINATION ${MODULE_DESTINATION}

+ 2 - 0
panda/src/eagldisplay/CMakeLists.txt

@@ -24,6 +24,8 @@ composite_sources(p3eagldisplay P3EAGLDISPLAY_SOURCES)
 add_component_library(p3eagldisplay SYMBOL BUILDING_PANDA_EAGLDISPLAY
   ${P3EAGLDISPLAY_HEADERS} ${P3EAGLDISPLAY_SOURCES})
 target_link_libraries(p3eagldisplay p3gles2gsg panda)
+
+target_include_directories(p3eagldisplay PUBLIC ${PYTHON_INCLUDE_DIRS})
 target_compile_options(p3eagldisplay PRIVATE -fobjc-arc)
 
 # Frameworks: