diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2019-07-24 14:50:36 -0400 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-07-31 20:45:59 +0200 |
commit | ad7d16a5b3b72fd2af2c98535a2358d8eaaf9b74 (patch) | |
tree | 298459b7de706a7a2e3415806494b1b20fa9a119 /cmake | |
parent | b8d69307eeb792ca0f18e3651f118bfe37cb7ff7 (diff) | |
download | weechat-ad7d16a5b3b72fd2af2c98535a2358d8eaaf9b74.zip |
build: use pkg-config to properly link python
fixes incorrect (non)detection of libpython3.Ym.so due to PEP 3149 since
python's officially exported build flags know how to correctly link to
python.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindPython.cmake | 78 |
1 files changed, 6 insertions, 72 deletions
diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index a5ba729ab..2e71e4c57 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -24,80 +24,14 @@ # code sets the following variables: # # PYTHON_EXECUTABLE = full path to the python binary -# PYTHON_INCLUDE_PATH = path to where python.h can be found -# PYTHON_LIBRARY = path to where libpython.so* can be found -# PYTHON_LFLAGS = python compiler options for linking +# PYTHON_INCLUDE_DIRS = path to where python.h can be found +# PYTHON_LIBRARIES = path to where libpython.so* can be found +# PYTHON_LDFLAGS = python compiler options for linking -if(PYTHON_FOUND) - # Already in cache, be silent - set(PYTHON_FIND_QUIETLY TRUE) -endif() +include(FindPkgConfig) if(ENABLE_PYTHON2) - find_program(PYTHON_EXECUTABLE - NAMES python2.7 python2.6 python2.5 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python - PATHS /usr/bin /usr/local/bin /usr/pkg/bin - ) + pkg_check_modules(PYTHON python2) else() - find_program(PYTHON_EXECUTABLE - NAMES python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python - PATHS /usr/bin /usr/local/bin /usr/pkg/bin - ) -endif() - -if(PYTHON_EXECUTABLE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import *; sys.stdout.write(get_config_var('INCLUDEPY'))" - OUTPUT_VARIABLE PYTHON_INC_DIR - ) - - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import *; sys.stdout.write(get_config_var('LIBPL'))" - OUTPUT_VARIABLE PYTHON_POSSIBLE_LIB_PATH - ) - - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import *; sys.stdout.write(get_config_var('LIBS') + ' ' + get_config_var('LINKFORSHARED'))" - OUTPUT_VARIABLE PYTHON_LFLAGS - ) - - find_path(PYTHON_INCLUDE_PATH - NAMES Python.h - HINTS ${PYTHON_INC_DIR} - ) - if(ENABLE_PYTHON2) - find_library(PYTHON_LIBRARY - NAMES python2.7 python2.6 python2.5 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python - HINTS ${PYTHON_POSSIBLE_LIB_PATH} - ) - else() - find_library(PYTHON_LIBRARY - NAMES python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python - HINTS ${PYTHON_POSSIBLE_LIB_PATH} - ) - endif() - - if(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" - OUTPUT_VARIABLE PYTHON_VERSION - ) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(str(sys.version_info < (2,5)))" - OUTPUT_VARIABLE PYTHON_OLD_VERSION - ) - if(${PYTHON_OLD_VERSION} STREQUAL "True") - message("Python >= 2.5 is needed to build python plugin, version found: ${PYTHON_VERSION}") - else() - set(PYTHON_FOUND TRUE) - endif() - endif() - - mark_as_advanced( - PYTHON_EXECUTABLE - PYTHON_INCLUDE_PATH - PYTHON_LIBRARY - PYTHON_LFLAGS - ) - + pkg_check_modules(PYTHON python3) endif() |