Use CMake FindPython3 module, raises minimum CMake to 3.12

Gives us out-of-the-box future proof python detection (python-3.9 right now).
parent 2f12fdf2
Pipeline #37905 passed with stage
in 26 minutes and 53 seconds
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
cmake_minimum_required (VERSION 3.12 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......
find_package(PkgConfig)
pkg_check_modules(PYTHONLIBS3 QUIET python3)
set(PYTHONLIBS3_DEFINITIONS ${PYTHONLIBS3_CFLAGS_OTHER})
find_path(PYTHONLIBS3_INCLUDE_DIR Python.h
HINTS ${PYTHONLIBS3_INCLUDEDIR} ${PYTHONLIBS3_INCLUDE_DIRS})
IF(WIN32)
find_library(PYTHONLIBS3_LIBRARY NAMES python32 python33 python34 python35 python36 python37 python38
HINTS ${PYTHONLIBS3_LIBDIR} ${PYTHONLIBS3_LIBRARY_DIRS} )
ELSE()
find_library(PYTHONLIBS3_LIBRARY NAMES python3.2m python3.3m python3.4m python3.5m python3.6m python3.7m python3.8
HINTS ${PYTHONLIBS3_LIBDIR} ${PYTHONLIBS3_LIBRARY_DIRS} )
ENDIF()
set(PYTHONLIBS3_LIBRARIES ${PYTHONLIBS3_LIBRARY} )
set(PYTHONLIBS3_INCLUDE_DIRS ${PYTHONLIBS3_INCLUDE_DIR} )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PythonLibs3 DEFAULT_MSG
PYTHONLIBS3_LIBRARY PYTHONLIBS3_INCLUDE_DIR)
mark_as_advanced(PYTHONLIBS3_INCLUDE_DIR PYTHONLIBS3_LIBRARY)
......@@ -50,15 +50,13 @@ if(QALCULATE_FOUND)
add_subdirectory(qalculate)
endif(QALCULATE_FOUND)
set_package_properties(PythonLibs3 PROPERTIES DESCRIPTION "A powerful dynamic programming language."
URL "https://www.python.org/"
TYPE OPTIONAL
set_package_properties(Python3 PROPERTIES TYPE OPTIONAL
PURPOSE "Backend to use Python with Cantor.")
find_package(PythonLibs3)
if(PYTHONLIBS3_FOUND)
find_package(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND)
add_subdirectory(python)
endif(PYTHONLIBS3_FOUND)
endif()
set_package_properties(LuaJIT PROPERTIES DESCRIPTION "A lightweight, extensible programming language (luajit implementation)."
URL "https://www.lua.org/"
......
......@@ -14,8 +14,6 @@ set(PythonServer_SRCS
pythonserver.cpp
)
include_directories(${PYTHONLIBS3_INCLUDE_DIRS})
qt5_add_resources(PythonBackend_RSCS python.qrc)
ki18n_wrap_ui(PythonBackend_SRCS settings.ui)
kconfig_add_kcfg_files(PythonBackend_SRCS settings.kcfgc)
......@@ -34,7 +32,7 @@ set_target_properties(cantor_pythonserver PROPERTIES INSTALL_RPATH_USE_LINK_PATH
if(MSVC)
set_property(TARGET cantor_pythonserver PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE")
endif()
target_link_libraries(cantor_pythonserver ${PYTHONLIBS3_LIBRARIES})
target_link_libraries(cantor_pythonserver Python3::Python)
if(BUILD_TESTING)
add_executable(testpython testpython.cpp settings.cpp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment