2016-04-12 16:22:53 +01:00
|
|
|
|
2016-12-10 07:02:46 +00:00
|
|
|
option (WITH_PYTHON
|
2017-02-20 15:28:46 +00:00
|
|
|
"Allow Python->YAP and YAP->Python" ON)
|
2016-12-10 07:02:46 +00:00
|
|
|
|
2017-02-20 15:28:46 +00:00
|
|
|
|
|
|
|
# PYTHONLIBS_FOUND - have the Python libs been found
|
|
|
|
# PYTHON_LIBRARIES - path to the python library
|
|
|
|
# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
|
|
|
|
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
|
|
|
|
# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
|
|
|
|
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
|
|
|
|
#
|
|
|
|
#
|
2016-12-10 07:02:46 +00:00
|
|
|
IF (WITH_PYTHON)
|
2017-02-20 15:28:46 +00:00
|
|
|
set (Python_ADDITIONAL_VERSIONS 3.5 3.6 3.4 3.3)
|
|
|
|
|
|
|
|
find_package(PythonInterp)
|
|
|
|
# find_package(PythonLibs)
|
|
|
|
|
|
|
|
|
|
|
|
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'include' ) )"
|
|
|
|
OUTPUT_VARIABLE _ABS_PYTHON_INCLUDE_PATH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
|
|
|
get_filename_component ( ABS_PYTHON_INCLUDE_PATH ${_ABS_PYTHON_INCLUDE_PATH} ABSOLUTE )
|
|
|
|
|
|
|
|
set ( PYTHON_INCLUDE_DIR
|
|
|
|
${ABS_PYTHON_INCLUDE_PATH}
|
|
|
|
CACHE "PATH" "Directory with Python.h "
|
|
|
|
)
|
|
|
|
|
|
|
|
set ( PYTHON_INCLUDE_DIRS
|
|
|
|
${ABS_PYTHON_INCLUDE_PATH}
|
|
|
|
CACHE "PATH" "Python.h Dir (Deprecated)"
|
|
|
|
)
|
|
|
|
|
|
|
|
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'stdlib' ) )"
|
|
|
|
OUTPUT_VARIABLE _ABS_PYTHON_SYSLIB_PATH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
2016-04-12 16:22:53 +01:00
|
|
|
|
2017-02-22 08:56:20 +00:00
|
|
|
find_library(ABS_PYTHON_SYSLIB_PATH
|
|
|
|
NAMES python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m
|
|
|
|
PATHS _ABS_PYTHON_SYSLIB_PATH
|
|
|
|
)
|
2017-02-20 15:28:46 +00:00
|
|
|
|
|
|
|
set ( PYTHON_LIBRARY
|
|
|
|
${ABS_PYTHON_SYSLIB_PATH}
|
|
|
|
CACHE "FILEPATH" "Python Library"
|
|
|
|
)
|
|
|
|
set ( PYTHON_LIBRARIES
|
|
|
|
${PYTHON_LIBRARY}
|
|
|
|
CACHE "FILEPATH" "Python Library (Deprecated)"
|
|
|
|
)
|
2017-02-22 08:56:20 +00:00
|
|
|
if ( (EXISTS ${PYTHON_LIBRARY}) AND ( EXISTS ${PYTHON_INCLUDE_DIR}) )
|
|
|
|
set ( PYTHONLIBS_FOUND ON )
|
|
|
|
# else()
|
|
|
|
|
|
|
|
#find_package(PythonLibs)
|
2016-04-12 16:22:53 +01:00
|
|
|
endif()
|
|
|
|
|
2017-02-20 15:28:46 +00:00
|
|
|
macro_log_feature (PYTHONLIBS_FOUND "Python"
|
|
|
|
"Use Python System"
|
2017-02-22 08:56:20 +00:00
|
|
|
"http://www.python.org" FALSE )
|
2016-04-12 16:22:53 +01:00
|
|
|
|
2016-10-16 23:18:51 +01:00
|
|
|
|
2017-02-20 15:28:46 +00:00
|
|
|
include_directories( BEFORE ${PYTHON_INCLUDE_DIR} )
|
2016-10-16 23:18:51 +01:00
|
|
|
|
2017-02-20 15:28:46 +00:00
|
|
|
LIST( APPEND
|
2017-02-22 08:56:20 +00:00
|
|
|
CMAKE_REQUIRED_INCLUDES ${PYTHON_INCLUDE_DIR} ${CMAKE_REQUIRED_INCLUDES})
|
2017-02-20 15:28:46 +00:00
|
|
|
|
|
|
|
check_include_file(Python.h HAVE_PYTHON_H)
|
2016-12-10 07:02:46 +00:00
|
|
|
|
|
|
|
|
2017-02-22 08:56:20 +00:00
|
|
|
endif(WITH_PYTHON)
|