From d6d6df83ef7e970f274277564db1f1b8e067db99 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 13 Jun 2018 18:42:50 -0600 Subject: [PATCH] CMake: Move Python detection to Package.cmake --- dtool/Config.cmake | 40 ---------------------------------------- dtool/Package.cmake | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/dtool/Config.cmake b/dtool/Config.cmake index 4c38728b51..168faf2fca 100644 --- a/dtool/Config.cmake +++ b/dtool/Config.cmake @@ -417,46 +417,6 @@ mark_as_advanced(ANDROID_NDK_HOME ANDROID_ABI ANDROID_STL # Now let's check for the presence of various thirdparty libraries. # -# Is Python installed, and should Python interfaces be generated? -set(WANT_PYTHON_VERSION "" - 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 -is also enabled, Python bindings will be generated.") - -# 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 - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} - -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))" - OUTPUT_VARIABLE _ARCH_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - 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 # python if he has to--that is, on Windows when building a debug build. diff --git a/dtool/Package.cmake b/dtool/Package.cmake index ae3afb0789..468b123ea5 100644 --- a/dtool/Package.cmake +++ b/dtool/Package.cmake @@ -1,3 +1,46 @@ +# +# ------------ Python ------------ +# + +set(WANT_PYTHON_VERSION "" + 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 +is also enabled, Python bindings will be generated.") + +# 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 + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} + -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))" + OUTPUT_VARIABLE _ARCH_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + 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() + # # ------------ Eigen ------------ #