From ac6842656e22f8a04299eca394f6c8fc7af8a9ef Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 17:06:24 +0200 Subject: [PATCH] enable qt6 or qt5 for mapnik-viewer. android could be dropped --- demo/viewer/CMakeLists.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 01fab3db8..790bcb33b 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -1,8 +1,9 @@ project(mapnik-viewer) -find_package(Qt5 COMPONENTS Widgets REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) -add_executable(mapnik-viewer +set(PROJECT_SOURCES about_dialog.cpp info_dialog.cpp layerdelegate.cpp @@ -19,6 +20,23 @@ add_executable(mapnik-viewer mapnik_viewer.qrc ) +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(mapnik-viewer + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +else() + if(ANDROID) + add_library(mapnik-viewer SHARED + ${PROJECT_SOURCES} + ) + else() + add_executable(mapnik-viewer + ${PROJECT_SOURCES} + ) + endif() +endif() + set_target_properties(mapnik-viewer PROPERTIES AUTOUIC_SEARCH_PATHS forms AUTORCC ON @@ -26,18 +44,23 @@ set_target_properties(mapnik-viewer PROPERTIES AUTOMOC ON ) - target_link_libraries(mapnik-viewer PRIVATE - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets mapnik::core mapnik::agg mapnik::mapnik ) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini "[mapnik] plugins_dir=${PLUGINS_INSTALL_DIR} fonts/1/dir=${FONTS_INSTALL_DIR}" ) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(mapnik-viewer) +endif() + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) mapnik_install(TARGET mapnik-viewer)