From ecdb1e2989e3bf86978590fc4fd724b18b8dde27 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Sat, 24 Jun 2023 17:25:28 +0100 Subject: [PATCH] Fix build with WITH_BINDINGS=yes and WITH_QTSERIALPORT=no MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit auto_generated/sensor/qgsabstractsensor.sip: In function ‘const sipTypeDef* sipSubClass_QgsAbstractSensor(void**)’: auto_generated/sensor/qgsabstractsensor.sip:35: error: ‘QgsSerialPortSensor’ does not name a type; did you mean ‘sipName_QgsSerialPortSensor’? --- python/CMakeLists.txt | 4 ++++ python/core/auto_generated/sensor/qgsabstractsensor.sip.in | 2 ++ python/core/auto_generated/sensor/qgsiodevicesensor.sip.in | 2 ++ python/core/core.sip.in | 1 + src/core/sensor/qgsabstractsensor.h | 2 ++ src/core/sensor/qgsiodevicesensor.h | 2 ++ 6 files changed, 13 insertions(+) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 38aca73dc57..e9a25f4e3fe 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -170,6 +170,10 @@ if(NOT WITH_GUI) set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_GUI) endif() +if(NOT WITH_QTSERIALPORT) + set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QTSERIALPORT) +endif() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core/project.py.in ${CMAKE_CURRENT_BINARY_DIR}/core/project.py @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core/pyproject.toml.in ${CMAKE_CURRENT_BINARY_DIR}/core/pyproject.toml @ONLY) GENERATE_SIP_PYTHON_MODULE_CODE(qgis._core core/core.sip "${sip_files_core}" cpp_files) diff --git a/python/core/auto_generated/sensor/qgsabstractsensor.sip.in b/python/core/auto_generated/sensor/qgsabstractsensor.sip.in index 5ed514f8d34..e75dc3ee25b 100644 --- a/python/core/auto_generated/sensor/qgsabstractsensor.sip.in +++ b/python/core/auto_generated/sensor/qgsabstractsensor.sip.in @@ -32,10 +32,12 @@ An abstract base class for sensor classes { sipType = sipType_QgsUdpSocketSensor; } +#if defined( HAVE_QTSERIALPORT ) else if ( item->type() == QLatin1String( "serial_port" ) && dynamic_cast( item ) != NULL ) { sipType = sipType_QgsSerialPortSensor; } +#endif else { sipType = sipType_QgsAbstractSensor; diff --git a/python/core/auto_generated/sensor/qgsiodevicesensor.sip.in b/python/core/auto_generated/sensor/qgsiodevicesensor.sip.in index b3c892fca42..3a094d3eda8 100644 --- a/python/core/auto_generated/sensor/qgsiodevicesensor.sip.in +++ b/python/core/auto_generated/sensor/qgsiodevicesensor.sip.in @@ -184,6 +184,7 @@ Sets the ``port`` the socket connects to. }; +%If (HAVE_QTSERIALPORT) class QgsSerialPortSensor : QgsIODeviceSensor { @@ -239,6 +240,7 @@ Sets the serial port the sensor connects to. }; +%End diff --git a/python/core/core.sip.in b/python/core/core.sip.in index 250ab320fbe..a860638bf93 100644 --- a/python/core/core.sip.in +++ b/python/core/core.sip.in @@ -100,6 +100,7 @@ done: %Import QtPositioning/QtPositioningmod.sip %Feature HAVE_GUI +%Feature HAVE_QTSERIALPORT %Feature ANDROID %Feature VECTOR_MAPPED_TYPE diff --git a/src/core/sensor/qgsabstractsensor.h b/src/core/sensor/qgsabstractsensor.h index 9474f3c88f7..a4b59743178 100644 --- a/src/core/sensor/qgsabstractsensor.h +++ b/src/core/sensor/qgsabstractsensor.h @@ -50,10 +50,12 @@ class CORE_EXPORT QgsAbstractSensor : public QObject { sipType = sipType_QgsUdpSocketSensor; } +#if defined( HAVE_QTSERIALPORT ) else if ( item->type() == QLatin1String( "serial_port" ) && dynamic_cast( item ) != NULL ) { sipType = sipType_QgsSerialPortSensor; } +#endif else { sipType = sipType_QgsAbstractSensor; diff --git a/src/core/sensor/qgsiodevicesensor.h b/src/core/sensor/qgsiodevicesensor.h index 690b67f2dca..68967e56d99 100644 --- a/src/core/sensor/qgsiodevicesensor.h +++ b/src/core/sensor/qgsiodevicesensor.h @@ -220,6 +220,7 @@ class CORE_EXPORT QgsUdpSocketSensor : public QgsIODeviceSensor }; #if defined( HAVE_QTSERIALPORT ) +SIP_IF_FEATURE( HAVE_QTSERIALPORT ) /** * \ingroup core @@ -279,6 +280,7 @@ class CORE_EXPORT QgsSerialPortSensor : public QgsIODeviceSensor QString mPortName; }; +SIP_END #endif #endif //QGSIODEVICESENSOR_H