Skip to content

Commit

Permalink
Merge pull request #42434 from 3nids/qt6-2
Browse files Browse the repository at this point in the history
more CmakeLists fixes for Qt6 + other fixes
  • Loading branch information
3nids committed Mar 24, 2021
2 parents ac0c927 + ea7fc3c commit 3b56d2d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
1 change: 1 addition & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -262,6 +262,7 @@ QVariant data types (such as strings, numeric values, dates and times)




QString qgsVsiPrefix( const QString &path );


Expand Down
46 changes: 27 additions & 19 deletions src/core/CMakeLists.txt
Expand Up @@ -803,7 +803,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(qgsspatialindex.cpp PROPERTIES COMPILE_FLAGS -Wno-overloaded-virtual)
endif()

if (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
if (QT_MOBILITY_LOCATION_FOUND OR ${QT_VERSION_BASE}Positioning_FOUND)
set(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
gps/qgsqtlocationconnection.cpp
)
Expand Down Expand Up @@ -1619,7 +1619,7 @@ if (NOT WITH_QTWEBKIT)
)
endif()

if (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
if (QT_MOBILITY_LOCATION_FOUND OR ${QT_VERSION_BASE}Positioning_FOUND)
set(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
)
Expand Down Expand Up @@ -1654,7 +1654,7 @@ endif()
# install qgsconfig.h and plugin.h here so they can get into
# the OS X framework target

if (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
if (QT_MOBILITY_LOCATION_FOUND OR ${QT_VERSION_BASE}Positioning_FOUND)
set(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
gps/qgsgpsconnectionregistry.h
Expand Down Expand Up @@ -1737,7 +1737,15 @@ add_library(qgis_core ${LIBRARY_TYPE} ${QGIS_CORE_SRCS} ${QGIS_CORE_HDRS} ${QGIS
target_compile_features(qgis_core PRIVATE cxx_std_17)

target_include_directories(qgis_core SYSTEM PUBLIC
${QT_INCLUDE_DIR}
${${QT_VERSION_BASE}Core_INCLUDE_DIRS}
${${QT_VERSION_BASE}Gui_INCLUDE_DIRS}
${${QT_VERSION_BASE}Xml_INCLUDE_DIRS}
${${QT_VERSION_BASE}Widgets_INCLUDE_DIRS}
${${QT_VERSION_BASE}Svg_INCLUDE_DIRS}
${${QT_VERSION_BASE}PrintSupport_INCLUDE_DIRS}
${${QT_VERSION_BASE}Network_INCLUDE_DIRS}
${${QT_VERSION_BASE}Sql_INCLUDE_DIRS}
${${QT_VERSION_BASE}Concurrent_INCLUDE_DIRS}
${PROJ_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${LIBZIP_INCLUDE_DIRS}
Expand All @@ -1748,7 +1756,7 @@ target_include_directories(qgis_core SYSTEM PUBLIC
${SPATIALITE_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
${Qt5SerialPort_INCLUDE_DIRS}
${${QT_VERSION_BASE}SerialPort_INCLUDE_DIRS}
${Protobuf_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
Expand Down Expand Up @@ -1821,7 +1829,7 @@ GENERATE_EXPORT_HEADER(
set(QGIS_CORE_HDRS ${QGIS_CORE_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_core.h)

if(ENABLE_MODELTEST)
target_link_libraries(qgis_core ${Qt5Test_LIBRARIES})
target_link_libraries(qgis_core ${${QT_VERSION_BASE}Test_LIBRARIES})
endif()

if (NOT WITH_INTERNAL_POLY2TRI)
Expand Down Expand Up @@ -1893,16 +1901,16 @@ if (ADD_CLAZY_CHECKS)
endif()

target_link_libraries(qgis_core
${Qt5Xml_LIBRARIES}
${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt5Svg_LIBRARIES}
${Qt5PrintSupport_LIBRARIES}
${Qt5Network_LIBRARIES}
${${QT_VERSION_BASE}Core_LIBRARIES}
${${QT_VERSION_BASE}Gui_LIBRARIES}
${${QT_VERSION_BASE}Xml_LIBRARIES}
${${QT_VERSION_BASE}Widgets_LIBRARIES}
${${QT_VERSION_BASE}Svg_LIBRARIES}
${${QT_VERSION_BASE}PrintSupport_LIBRARIES}
${${QT_VERSION_BASE}Network_LIBRARIES}
${${QT_VERSION_BASE}Sql_LIBRARIES}
${${QT_VERSION_BASE}Concurrent_LIBRARIES}
${OPTIONAL_QTWEBKIT}
${Qt5Sql_LIBRARIES}
${Qt5Concurrent_LIBRARIES}
${QCA_LIBRARY}
${QTKEYCHAIN_LIBRARY}
${PROJ_LIBRARY}
Expand Down Expand Up @@ -1946,15 +1954,15 @@ if (MSVC)
set(TARGET_LINK_LIBRARIES qgis_core odbc32 odbccp32)
endif()

if (Qt5SerialPort_FOUND)
if (${QT_VERSION_BASE}SerialPort_FOUND)
target_link_libraries(qgis_core
Qt5::SerialPort
${QT_VERSION_BASE}::SerialPort
)
endif()

if (Qt5Positioning_FOUND)
if (${QT_VERSION_BASE}Positioning_FOUND)
target_link_libraries(qgis_core
Qt5::Positioning
${QT_VERSION_BASE}::Positioning
)
endif()

Expand Down
2 changes: 2 additions & 0 deletions src/core/qgis.cpp
Expand Up @@ -295,10 +295,12 @@ QString Qgis::devVersion()
return QString::fromUtf8( QGIS_DEV_VERSION );
}

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
template<>
bool qMapLessThanKey<QVariantList>( const QVariantList &key1, const QVariantList &key2 )
{
// qt's built in qMapLessThanKey for QVariantList is broken and does a case-insensitive operation.
// this breaks QMap< QVariantList, ... >, where key matching incorrectly becomes case-insensitive..!!?!
return qgsVariantGreaterThan( key1, key2 ) && key1 != key2;
}
#endif
5 changes: 4 additions & 1 deletion src/core/qgis.h
Expand Up @@ -561,11 +561,14 @@ CORE_EXPORT bool qgsVariantEqual( const QVariant &lhs, const QVariant &rhs );
*/
CORE_EXPORT bool qgsVariantGreaterThan( const QVariant &lhs, const QVariant &rhs );


#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)

/**
* Compares two QVariantList values and returns whether the first is less than the second.
*/
template<> CORE_EXPORT bool qMapLessThanKey<QVariantList>( const QVariantList &key1, const QVariantList &key2 ) SIP_SKIP;

#endif

CORE_EXPORT QString qgsVsiPrefix( const QString &path );

Expand Down
2 changes: 2 additions & 0 deletions src/core/qgscoordinatetransformcontext.cpp
Expand Up @@ -26,6 +26,7 @@ QString crsToKey( const QgsCoordinateReferenceSystem &crs )
return crs.authid().isEmpty() ? crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : crs.authid();
}

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
template<>
bool qMapLessThanKey<QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem>>( const QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem> &key1,
const QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem> &key2 )
Expand All @@ -34,6 +35,7 @@ bool qMapLessThanKey<QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceS
const QPair< QString, QString > key2String = qMakePair( crsToKey( key2.first ), crsToKey( key2.second ) );
return key1String < key2String;
}
#endif

QgsCoordinateTransformContext::QgsCoordinateTransformContext()
: d( new QgsCoordinateTransformContextPrivate() )
Expand Down

0 comments on commit 3b56d2d

Please sign in to comment.