mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-18 06:30:54 +00:00
fix: allow cmake varibles from Python calls to be cached (#2570)
This commit is contained in:
parent
fecef38864
commit
d46f3322a4
@ -80,13 +80,20 @@ if(NOT DEFINED ${_Python}_EXECUTABLE)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED PYTHON_IS_DEBUG)
|
||||||
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
|
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${${_Python}_EXECUTABLE}" "-c" "import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
|
COMMAND "${${_Python}_EXECUTABLE}" "-c"
|
||||||
RESULT_VARIABLE PYTHON_IS_DEBUG)
|
"import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
|
||||||
|
RESULT_VARIABLE _PYTHON_IS_DEBUG)
|
||||||
|
set(PYTHON_IS_DEBUG
|
||||||
|
"${_PYTHON_IS_DEBUG}"
|
||||||
|
CACHE INTERNAL "Python debug status")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
|
# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
|
||||||
# required for PyPy3 (as of 7.3.1)
|
# required for PyPy3 (as of 7.3.1)
|
||||||
|
if(NOT DEFINED PYTHON_MODULE_EXTENSION)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${${_Python}_EXECUTABLE}" "-c"
|
COMMAND "${${_Python}_EXECUTABLE}" "-c"
|
||||||
"from distutils import sysconfig; print(sysconfig.get_config_var('SO'))"
|
"from distutils import sysconfig; print(sysconfig.get_config_var('SO'))"
|
||||||
@ -104,6 +111,7 @@ endif()
|
|||||||
set(PYTHON_MODULE_EXTENSION
|
set(PYTHON_MODULE_EXTENSION
|
||||||
"${_PYTHON_MODULE_EXTENSION}"
|
"${_PYTHON_MODULE_EXTENSION}"
|
||||||
CACHE INTERNAL "")
|
CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Python debug libraries expose slightly different objects before 3.8
|
# Python debug libraries expose slightly different objects before 3.8
|
||||||
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
|
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
|
||||||
|
Loading…
Reference in New Issue
Block a user