From cbeaec80c9c8e786afed9b6a38e615890a82321d Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Tue, 2 Mar 2021 09:51:31 +0100 Subject: cmake: python3 and package detection Change-Id: I4a180811dede6c69c2b627adbd184eb87abd2c43 Reviewed-by: Robert Griebl --- cmake/QtIviSetup.cmake | 37 ++++++++++++++++++ src/ivicore/.prev_configure.cmake | 82 +++++++++++++++++++++++++++++++++++++++ src/ivicore/configure.cmake | 49 ++++++++++++++++++----- 3 files changed, 159 insertions(+), 9 deletions(-) create mode 100644 cmake/QtIviSetup.cmake create mode 100644 src/ivicore/.prev_configure.cmake diff --git a/cmake/QtIviSetup.cmake b/cmake/QtIviSetup.cmake new file mode 100644 index 0000000..e536ff4 --- /dev/null +++ b/cmake/QtIviSetup.cmake @@ -0,0 +1,37 @@ +function(qt_config_python3_package_test name) + if(DEFINED "TEST_${name}") + return() + endif() + + cmake_parse_arguments(arg "" "LABEL;PACKAGE;VERSION" + "" ${ARGN}) + + message(STATUS "Performing Test ${arg_LABEL}") + + execute_process(COMMAND ${Python3_EXECUTABLE} "-c" "import pkg_resources; print(pkg_resources.get_distribution(\"${arg_PACKAGE}\").version)" + RESULT_VARIABLE ${name}_RESULT + OUTPUT_VARIABLE ${name}_VERSION + ERROR_QUIET + ) + + set(HAVE_${name} FALSE) + set(status_label "Failed") + + if(${${name}_RESULT} EQUAL 0) + if(DEFINED arg_VERSION) + message(STATUS "Checking for exact version:") + message(STATUS "Expected: ${arg_VERSION}") + message(STATUS "Got: ${${name}_VERSION}") + if("${arg_VERSION}" VERSION_EQUAL "${${name}_VERSION}") + set(HAVE_${name} TRUE) + set(status_label "Success") + endif() + else() + set(HAVE_${name} TRUE) + set(status_label "Success") + endif() + endif() + message(STATUS "Performing Test ${arg_LABEL} - ${status_label}") + + set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}") +endfunction() diff --git a/src/ivicore/.prev_configure.cmake b/src/ivicore/.prev_configure.cmake new file mode 100644 index 0000000..3295315 --- /dev/null +++ b/src/ivicore/.prev_configure.cmake @@ -0,0 +1,82 @@ + + +#### Inputs + +# input ivigenerator +set(INPUT_ivigenerator "undefined" CACHE STRING "") +set_property(CACHE INPUT_ivigenerator PROPERTY STRINGS undefined no qt system) + +# input qface +set(INPUT_qface "undefined" CACHE STRING "") +set_property(CACHE INPUT_qface PROPERTY STRINGS undefined no qt system) + + + +#### Libraries + + + +#### Tests + + + +#### Features + +qt_feature("python3" PRIVATE + LABEL "python3" + CONDITION tests.python3 OR FIXME +) +qt_feature("python3-virtualenv" PRIVATE + LABEL "virtualenv" + CONDITION QT_FEATURE_python3 AND tests.virtualenv OR FIXME +) +qt_feature("system-qface" PUBLIC + LABEL "System QFace" + CONDITION tests.qface OR FIXME + ENABLE INPUT_qface STREQUAL 'system' + DISABLE INPUT_qface STREQUAL 'no' OR INPUT_qface STREQUAL 'qt' +) +qt_feature("system-ivigenerator" PRIVATE + LABEL "System IVI Generator" + ENABLE INPUT_ivigenerator STREQUAL 'system' + DISABLE ( NOT INPUT_ivigenerator STREQUAL 'system' ) +) +qt_feature("ivigenerator" PUBLIC + LABEL "IVI Generator" + CONDITION QT_FEATURE_ivicore AND QT_FEATURE_python3 AND ( ( QT_FEATURE_python3_virtualenv AND tests.qface-submodule ) OR ( QT_FEATURE_system_qface ) ) OR QT_FEATURE_system_ivigenerator OR FIXME + ENABLE INPUT_ivigenerator STREQUAL 'qt' OR INPUT_ivigenerator STREQUAL 'system' + DISABLE INPUT_ivigenerator STREQUAL 'no' +) +qt_feature("host-tools-only" PRIVATE + LABEL "Only build the host tools" + CONDITION INPUT_host_tools_only STREQUAL 'yes' +) +qt_feature("remoteobjects" PUBLIC + LABEL "QtRemoteObjects Support" + CONDITION TARGET Qt::RemoteObjects OR INPUT_force_ivigenerator_qtremoteobjects STREQUAL 'yes' +) +qt_feature("ivicore" PUBLIC + LABEL "Qt IVI Core" +) +qt_configure_add_summary_section(NAME "Qt IVI Core") +qt_configure_add_summary_section(NAME "Python3") +qt_configure_add_summary_entry(ARGS "python3-virtualenv") +qt_configure_add_summary_entry(ARGS "system-qface") +qt_configure_end_summary_section() # end of "Python3" section +qt_configure_add_summary_entry(ARGS "ivigenerator") +qt_configure_add_summary_entry(ARGS "remoteobjects") +qt_configure_end_summary_section() # end of "Qt IVI Core" section +qt_configure_add_summary_entry( + ARGS "ivicore" + CONDITION NOT QT_FEATURE_ivicore +) +qt_configure_add_report_entry( + TYPE ERROR + MESSAGE "Cannot build the IVI Generator because its dependencies are not satisfied. The IVI Generator provides tooling to generate source code out of IDL files. Make sure python3 and its 'virtualenv' packages are installed. E.g. by running apt-get install python3 python3-virtualenv And make sure the qface submodule is initialized or the correct qface version is installed on your system. E.g. by running the following command: git submodule init && git submodule update" + CONDITION QT_FEATURE_ivicore AND NOT QT_FEATURE_ivigenerator AND ( NOT INPUT_ivigenerator STREQUAL 'no' ) +) +qt_configure_add_report_entry( + TYPE WARNING + MESSAGE "Cannot enable the QtRemoteObjects features because the QtRemoteObjects module is not installed." + CONDITION NOT QT_FEATURE_remoteobjects +) diff --git a/src/ivicore/configure.cmake b/src/ivicore/configure.cmake index 3b68db0..8b94aed 100644 --- a/src/ivicore/configure.cmake +++ b/src/ivicore/configure.cmake @@ -1,4 +1,9 @@ - +# special case begin +# Define a stub for qt-configure-module +if (NOT COMMAND qt_config_python3_package_test) + defstub(qt_config_python3_package_test) +endif() +# special case end #### Inputs @@ -14,25 +19,33 @@ set_property(CACHE INPUT_qface PROPERTY STRINGS undefined no qt system) #### Libraries - +qt_find_package(Python3 PROVIDED_TARGETS Python3::Interpreter MODULE_NAME ivicore) #### Tests - +qt_config_python3_package_test(virtualenv + LABEL "Python3 virtualenv package" + PACKAGE "virtualenv" +) +qt_config_python3_package_test(qface + LABEL "Python3 qface package" + PACKAGE "qface" + VERSION "2.0.3" +) #### Features qt_feature("python3" PRIVATE LABEL "python3" - CONDITION tests.python3 OR FIXME + CONDITION PYTHON3_FOUND ) qt_feature("python3-virtualenv" PRIVATE LABEL "virtualenv" - CONDITION QT_FEATURE_python3 AND tests.virtualenv OR FIXME + CONDITION QT_FEATURE_python3 AND TEST_virtualenv ) qt_feature("system-qface" PUBLIC LABEL "System QFace" - CONDITION tests.qface OR FIXME + CONDITION TEST_qface ENABLE INPUT_qface STREQUAL 'system' DISABLE INPUT_qface STREQUAL 'no' OR INPUT_qface STREQUAL 'qt' ) @@ -43,7 +56,7 @@ qt_feature("system-ivigenerator" PRIVATE ) qt_feature("ivigenerator" PUBLIC LABEL "IVI Generator" - CONDITION QT_FEATURE_ivicore AND QT_FEATURE_python3 AND ( ( QT_FEATURE_python3_virtualenv AND tests.qface-submodule ) OR ( QT_FEATURE_system_qface ) ) OR QT_FEATURE_system_ivigenerator OR FIXME + CONDITION QT_FEATURE_ivicore AND QT_FEATURE_python3 AND ( ( QT_FEATURE_python3_virtualenv AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/../3rdparty/qface/setup.py" ) OR ( QT_FEATURE_system_qface ) ) OR QT_FEATURE_system_ivigenerator # special case ENABLE INPUT_ivigenerator STREQUAL 'qt' OR INPUT_ivigenerator STREQUAL 'system' DISABLE INPUT_ivigenerator STREQUAL 'no' ) @@ -60,6 +73,12 @@ qt_feature("ivicore" PUBLIC ) qt_configure_add_summary_section(NAME "Qt IVI Core") qt_configure_add_summary_section(NAME "Python3") +if(PYTHON3_FOUND) + qt_configure_add_summary_entry(TYPE "message" ARGS "Executable" MESSAGE "${Python3_EXECUTABLE}") + qt_configure_add_summary_entry(TYPE "message" ARGS "Version" MESSAGE "${Python3_VERSION}") +else() + qt_configure_add_summary_entry(TYPE "message" ARGS "Executable" MESSAGE "no") +endif() qt_configure_add_summary_entry(ARGS "python3-virtualenv") qt_configure_add_summary_entry(ARGS "system-qface") qt_configure_end_summary_section() # end of "Python3" section @@ -71,8 +90,20 @@ qt_configure_add_summary_entry( CONDITION NOT QT_FEATURE_ivicore ) qt_configure_add_report_entry( - TYPE WARNING - MESSAGE "Cannot build the IVI Generator because its dependencies are not satisfied. The IVI Generator provides tooling to generate source code out of IDL files. Make sure python3 and its 'virtualenv' packages are installed. E.g. by running apt-get install python3 python3-virtualenv And make sure the qface submodule is initialized or the correct qface version is installed on your system. E.g. by running the following command: git submodule init && git submodule update" + TYPE ERROR +# special case begin + MESSAGE [[ +Cannot build the IVI Generator because its dependencies are not satisfied. +The IVI Generator provides tooling to generate source code out of IDL files. +Make sure python3 and its 'virtualenv' packages are installed. +E.g. by running + apt-get install python3 python3-virtualenv + +And make sure the qface submodule is initialized or the correct qface version is installed on your system. +E.g. by running the following command: + git submodule init && git submodule update +]] +# special case end CONDITION QT_FEATURE_ivicore AND NOT QT_FEATURE_ivigenerator AND ( NOT INPUT_ivigenerator STREQUAL 'no' ) ) qt_configure_add_report_entry( -- cgit v1.2.3