Преглед изворни кода

CMake: When HAVE_PYTHON, detect the Python install directories. Also, only include Python directories if HAVE_PYTHON.

Sam Edwards пре 12 година
родитељ
комит
5e78a80acc
1 измењених фајлова са 22 додато и 3 уклоњено
  1. 22 3
      dtool/Config.cmake

+ 22 - 3
dtool/Config.cmake

@@ -437,9 +437,28 @@ package_option(PYTHON DEFAULT ON
   "Enables support for Python.  If INTERROGATE_PYTHON_INTERFACE
   "Enables support for Python.  If INTERROGATE_PYTHON_INTERFACE
 is also enabled, Python bindings will be generated.")
 is also enabled, Python bindings will be generated.")
 
 
-# Always include Python, because we include it pretty much everywhere
-# though we don't usually want to link it in as well.
-include_directories(${PYTHON_INCLUDE_DIRS})
+# Also detect the optimal install paths:
+if(HAVE_PYTHON)
+  execute_process(
+    COMMAND ${PYTHON_EXECUTABLE}
+      -c "from distutils.sysconfig import get_python_lib; print get_python_lib(False)"
+      OUTPUT_VARIABLE _LIB_DIR)
+  execute_process(
+    COMMAND ${PYTHON_EXECUTABLE}
+      -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True)"
+      OUTPUT_VARIABLE _ARCH_DIR)
+
+  set(PYTHON_LIB_INSTALL_DIR "${_LIB_DIR}" CACHE STRING
+    "Path to the Python architecture-independent package directory.")
+
+  set(PYTHON_ARCH_INSTALL_DIR "${_ARCH_DIR}" CACHE STRING
+    "Path to the Python architecture-dependent package directory.")
+
+  # Always include Python, because we include it pretty much everywhere
+  # though we don't usually want to link it in as well.
+  include_directories(${PYTHON_INCLUDE_DIRS})
+endif()
+
 
 
 # By default, we'll assume the user only wants to run with Debug
 # By default, we'll assume the user only wants to run with Debug
 # python if he has to--that is, on Windows when building a debug build.
 # python if he has to--that is, on Windows when building a debug build.