Browse Source

CMake: Support targeting Python 3

Sam Edwards 7 years ago
parent
commit
b68b6caeb0
3 changed files with 14 additions and 7 deletions
  1. 1 1
      cmake/macros/Interrogate.cmake
  2. 12 5
      dtool/Config.cmake
  3. 1 1
      dtool/LocalSetup.cmake

+ 1 - 1
cmake/macros/Interrogate.cmake

@@ -206,7 +206,7 @@ function(interrogate_sources target output database module)
         ${define_flags}
         -S "${PROJECT_BINARY_DIR}/include"
         -S "${PROJECT_SOURCE_DIR}/dtool/src/parser-inc"
-        -S "${PROJECT_BINARY_DIR}/include/parser-inc"
+        -S "${PYTHON_INCLUDE_DIRS}"
         ${include_flags}
         ${scan_sources}
         ${extensions}

+ 12 - 5
dtool/Config.cmake

@@ -444,9 +444,16 @@ endif()
 
 
 # Is Python installed, and should Python interfaces be generated?
-find_package(PythonLibs 2.5)
-find_package(PythonInterp 2.5)
-set(PYTHON_FOUND ${PYTHONLIBS_FOUND})
+set(WANT_PYTHON_VERSION "2.7"
+  CACHE STRING "Which Python version to seek out for building Panda3D against.")
+
+find_package(PythonInterp ${WANT_PYTHON_VERSION} QUIET)
+find_package(PythonLibs ${PYTHON_VERSION_STRING} QUIET)
+if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
+  set(PYTHON_FOUND ON)
+else()
+  set(PYTHON_FOUND OFF)
+endif()
 
 package_option(PYTHON DEFAULT ON
   "Enables support for Python.  If INTERROGATE_PYTHON_INTERFACE
@@ -456,12 +463,12 @@ is also enabled, Python bindings will be generated.")
 if(HAVE_PYTHON)
   execute_process(
     COMMAND ${PYTHON_EXECUTABLE}
-      -c "from distutils.sysconfig import get_python_lib; print get_python_lib(False)"
+      -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False))"
       OUTPUT_VARIABLE _LIB_DIR
       OUTPUT_STRIP_TRAILING_WHITESPACE)
   execute_process(
     COMMAND ${PYTHON_EXECUTABLE}
-      -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True)"
+      -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
       OUTPUT_VARIABLE _ARCH_DIR
       OUTPUT_STRIP_TRAILING_WHITESPACE)
 

+ 1 - 1
dtool/LocalSetup.cmake

@@ -448,7 +448,7 @@ endif()
 
 message("")
 if(HAVE_INTERROGATE AND HAVE_PYTHON)
-  message("Compilation will generate Python interfaces.")
+  message("Compilation will generate Python interfaces for Python ${PYTHON_VERSION_STRING}.")
 else()
   message("Configuring Panda WITHOUT Python interfaces.")
 endif()