Find PythonQt.

This commit is contained in:
Teo Mrnjavac 2016-10-02 17:02:55 +02:00
parent b801efe1c9
commit ada620effc
3 changed files with 89 additions and 2 deletions

View File

@ -55,9 +55,10 @@ find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools S
find_package( YAMLCPP 0.5.1 REQUIRED ) find_package( YAMLCPP 0.5.1 REQUIRED )
find_package( PolkitQt5-1 REQUIRED ) find_package( PolkitQt5-1 REQUIRED )
option( WITH_PYTHON "Enable Python modules support." ON ) option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
option( WITH_CRASHREPORTER "Build with CrashReporter" ON ) option( WITH_CRASHREPORTER "Build with CrashReporter" ON )
option( INSTALL_CONFIG "Install configuration files" ON) option( INSTALL_CONFIG "Install configuration files" ON)
option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libcrashreporter-qt/CMakeLists.txt" ) if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libcrashreporter-qt/CMakeLists.txt" )
message( STATUS "Build of crashreporter disabled." ) message( STATUS "Build of crashreporter disabled." )
@ -85,11 +86,23 @@ if ( PYTHONLIBS_FOUND )
FALSE "1.54.0" FALSE "1.54.0"
"Boost.Python is used for interfacing with Calamares job modules written in Python 3." "Boost.Python is used for interfacing with Calamares job modules written in Python 3."
) )
macro_optional_find_package( PythonQt )
macro_log_feature( PYTHONQT_FOUND
"PythonQt"
"A Python embedding solution for Qt applications."
"http://pythonqt.sourceforge.net"
FALSE "3.1"
"PythonQt is used for the Python modules API."
)
endif() endif()
if ( PYTHONLIBS_NOTFOUND OR NOT CALAMARES_BOOST_PYTHON3_FOUND ) if ( PYTHONLIBS_NOTFOUND OR NOT CALAMARES_BOOST_PYTHON3_FOUND )
set( WITH_PYTHON OFF ) set( WITH_PYTHON OFF )
endif() endif()
if ( PYTHONLIBS_NOTFOUND OR NOT PYTHONQT_FOUND )
set( WITH_PYTHONQT OFF )
endif()
### ###
### Calamares application info ### Calamares application info
@ -168,8 +181,12 @@ add_subdirectory( src )
macro_display_feature_log() macro_display_feature_log()
if ( NOT WITH_PYTHON ) if ( NOT WITH_PYTHON )
message( "-- WARNING: Building Calamares without Python support. Python modules will not work.\n" ) message( "-- WARNING: Building Calamares without Python support. Legacy Python job modules will not work.\n" )
endif() endif()
if ( NOT WITH_PYTHONQT )
message( "-- WARNING: Building Calamares without PythonQt support. Python modules will not work.\n" )
endif()
if ( NOT INSTALL_CONFIG ) if ( NOT INSTALL_CONFIG )
message( "-- WARNING: Configuration files will not be installed.\n" ) message( "-- WARNING: Configuration files will not be installed.\n" )

View File

@ -0,0 +1,69 @@
# Find PythonQt
#
# Sets PYTHONQT_FOUND, PYTHONQT_INCLUDE_DIR, PYTHONQT_LIBRARY, PYTHONQT_LIBRARIES
#
# Python is required
find_package(PythonLibs)
if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "error: Python is required to build PythonQt")
endif()
if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}")
find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.")
endif()
# XXX Since PythonQt 3.0 is not yet cmakeified, depending
# on how PythonQt is built, headers will not always be
# installed in "include/PythonQt". That is why "src"
# is added as an option. See [1] for more details.
# [1] https://github.com/commontk/CTK/pull/538#issuecomment-86106367
find_path(PYTHONQT_INCLUDE_DIR PythonQt.h
PATHS "${PYTHONQT_INSTALL_DIR}/include/PythonQt"
"${PYTHONQT_INSTALL_DIR}/src"
DOC "Path to the PythonQt include directory")
find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt${CTK_CMAKE_DEBUG_POSTFIX} PythonQt${CMAKE_DEBUG_POSTFIX} PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
find_library(PYTHONQT_QTALL_LIBRARY_RELEASE PythonQt_QtAll PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.")
find_library(PYTHONQT_QTALL_LIBRARY_DEBUG NAMES PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX} PythonQt_QtAll${CMAKE_DEBUG_POSTFIX} PythonQt_QtAll PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.")
set(PYTHONQT_LIBRARY)
if(PYTHONQT_LIBRARY_RELEASE)
list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
endif()
if(PYTHONQT_LIBRARY_DEBUG)
list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
endif()
set(PYTHONQT_QTALL_LIBRARY)
if(PYTHONQT_QTALL_LIBRARY_RELEASE)
list(APPEND PYTHONQT_QTALL_LIBRARY optimized ${PYTHONQT_QTALL_LIBRARY_RELEASE})
endif()
if(PYTHONQT_QTALL_LIBRARY_DEBUG)
list(APPEND PYTHONQT_QTALL_LIBRARY debug ${PYTHONQT_QTALL_LIBRARY_DEBUG})
endif()
mark_as_advanced(PYTHONQT_INSTALL_DIR)
mark_as_advanced(PYTHONQT_INCLUDE_DIR)
mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)
mark_as_advanced(PYTHONQT_LIBRARY_DEBUG)
mark_as_advanced(PYTHONQT_QTALL_LIBRARY_RELEASE)
mark_as_advanced(PYTHONQT_QTALL_LIBRARY_DEBUG)
# On linux, also find libutil
if(UNIX AND NOT APPLE)
find_library(PYTHONQT_LIBUTIL util)
mark_as_advanced(PYTHONQT_LIBUTIL)
endif()
# All upper case _FOUND variable is maintained for backwards compatibility.
set(PYTHONQT_FOUND 0)
set(PythonQt_FOUND 0)
if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY AND PYTHONQT_QTALL_LIBRARY)
# Currently CMake'ified PythonQt only supports building against a python Release build.
# This applies independently of CTK build type (Release, Debug, ...)
add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
set(PYTHONQT_FOUND 1)
set(PythonQt_FOUND ${PYTHONQT_FOUND})
set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL} ${PYTHONQT_QTALL_LIBRARY})
endif()

View File

@ -11,5 +11,6 @@
//cmakedefines for CMake variables (e.g. for optdepends) go here //cmakedefines for CMake variables (e.g. for optdepends) go here
#cmakedefine WITH_PYTHON #cmakedefine WITH_PYTHON
#cmakedefine WITH_CRASHREPORTER #cmakedefine WITH_CRASHREPORTER
#cmakedefine WITH_PYTHONQT
#endif // CALAMARESCONFIG_H #endif // CALAMARESCONFIG_H