From fd6974ca653130a49da351547e476446c91e7ffc Mon Sep 17 00:00:00 2001 From: jihadist Date: Sun, 13 Oct 2024 21:41:33 +0300 Subject: [PATCH] cmake: add options ENABLE_DIALOG_DESIGNER and HAVE_UI_LOADER --- CMakeLists.txt | 91 ++++++++++++++++--- console/CMakeLists.txt | 17 ++++ demo_r1/CMakeLists.txt | 1 + demo_r2/CMakeLists.txt | 25 +++++ .../dialogdesigner/lrdialogdesigner.cpp | 3 +- limereport/lrfactoryinitializer.cpp | 2 + 6 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 console/CMakeLists.txt create mode 100644 demo_r2/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b98eca..c1edeca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,22 +9,42 @@ set(DEFAULT_ITEM_PADDING 0) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) option(LIMEREPORT_DEMO "Build LimeReport demos" OFF) +option(ENABLE_DIALOG_DESIGNER "Enable dialog designer" OFF) +option(HAVE_UI_LOADER "Enable ui loader" OFF) option(USE_QT6 "Use Qt6" OFF) +if (ENABLE_DIALOG_DESIGNER AND NOT HAVE_UI_LOADER) + message(FATAL_ERROR "You need to enable HAVE_UI_LOADER") +endif() + if(USE_QT6) find_package(QT NAMES Qt6) else() find_package(QT NAMES Qt5) endif(USE_QT6) -find_package( - Qt${QT_VERSION_MAJOR} - COMPONENTS Core Widgets Sql Network Xml Svg Qml PrintSupport REQUIRED - ) find_package( Qt${QT_VERSION_MAJOR} - COMPONENTS UiTools - ) + COMPONENTS Core Widgets Sql Network Xml Svg Qml PrintSupport REQUIRED) + +if(HAVE_UI_LOADER) + find_package( + Qt${QT_VERSION_MAJOR} + COMPONENTS UiTools REQUIRED) + endif() + +if(ENABLE_DIALOG_DESIGNER) + if(USE_QT6) + if(ENABLE_DIALOG_DESIGNER) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Designer DesignerComponentsPrivate REQUIRED) + endif() + else() + if(ENABLE_DIALOG_DESIGNER) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Designer DesignerComponents REQUIRED) + endif() + endif(USE_QT6) + endif() + # Old Qt does not provide QT_VERSION_MAJOR if (NOT QT_VERSION_MAJOR) string(SUBSTRING ${QT_VERSION} 0 1 QT_VERSION_MAJOR) @@ -41,8 +61,10 @@ endif() add_subdirectory(3rdparty) if (LIMEREPORT_DEMO) + add_subdirectory(console) add_subdirectory(designer) add_subdirectory(demo_r1) + add_subdirectory(demo_r2) endif() set(CMAKE_AUTOMOC ON) @@ -318,7 +340,6 @@ ${PROJECT_NAME}/translationeditor/translationeditor.ui ${PROJECT_NAME}/databrowser/lrdatabrowser.qrc -${PROJECT_NAME}/dialogdesigner/dialogdesigner.qrc ${PROJECT_NAME}/items/items.qrc ${PROJECT_NAME}/objectinspector/lobjectinspector.qrc ${PROJECT_NAME}/report.qrc @@ -326,6 +347,28 @@ ${PROJECT_NAME}/scriptbrowser/lrscriptbrowser.qrc ${PROJECT_NAME}/translationeditor/translationeditor.qrc ) +if(ENABLE_DIALOG_DESIGNER) + set(DIALOG_DESIGNER_SOURCES + ${PROJECT_NAME}/dialogdesigner/lrdialogdesigner.h + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/namespace_global.h + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.h + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.h + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethostconstants.h + + ${PROJECT_NAME}/dialogdesigner/lrdialogdesigner.cpp + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp + ${PROJECT_NAME}/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.cpp + + ${PROJECT_NAME}/dialogdesigner/templates/Dialog.ui + ${PROJECT_NAME}/dialogdesigner/dialogdesigner.qrc) + + message(STATUS "DesignerComponents found") + list( APPEND LIMEREPORT_SOURCES ${DIALOG_DESIGNER_SOURCES} ) + +endif() + if (ENABLE_ZINT) list(APPEND LIMEREPORT_SOURCES ${PROJECT_NAME}/items/lrbarcodeitem.cpp) list(APPEND LIMEREPORT_SOURCES ${PROJECT_NAME}/items/lrbarcodeitem.h) @@ -369,11 +412,11 @@ else() target_compile_definitions( ${PROJECT_NAME} INTERFACE -DLIMEREPORT_IMPORTS) endif() -if(Qt${QT_VERSION_MAJOR}UiTools_FOUND) +if(HAVE_UI_LOADER) target_compile_definitions( ${PROJECT_NAME} PRIVATE -DHAVE_UI_LOADER) target_link_libraries( ${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::UiTools) -endif() + endif() target_link_libraries( ${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core @@ -384,6 +427,30 @@ target_link_libraries( ${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Svg) +if(ENABLE_DIALOG_DESIGNER) + target_compile_definitions(${PROJECT_NAME} PUBLIC -DHAVE_QTDESIGNER_INTEGRATION) + if(${QT_VERSION_MAJOR} STREQUAL 5) + target_link_libraries( ${PROJECT_NAME} PUBLIC + Qt${QT_VERSION_MAJOR}::Designer + Qt${QT_VERSION_MAJOR}::DesignerComponents) + endif() + + if(${QT_VERSION_MAJOR} STREQUAL 6) + target_link_libraries( ${PROJECT_NAME} PUBLIC + Qt${QT_VERSION_MAJOR}::Designer + Qt${QT_VERSION_MAJOR}::DesignerComponentsPrivate) + endif() + + target_include_directories( ${PROJECT_NAME} PRIVATE + limereport/dialogdesigner/3rdparty/qtcreator + limereport/dialogdesigner/3rdparty/designer + limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2) + + target_include_directories( ${PROJECT_NAME} PRIVATE + ${CMAKE_PREFIX_PATH}/include/QtDesigner/${QT_VERSION}/QtDesigner/private) + +endif(ENABLE_DIALOG_DESIGNER) + if(ENABLE_ZINT) target_link_libraries( ${PROJECT_NAME} PRIVATE QZint) endif(ENABLE_ZINT) @@ -391,8 +458,7 @@ endif(ENABLE_ZINT) target_compile_definitions( ${PROJECT_NAME} PRIVATE -DDEFAULT_ITEM_PADDING=${DEFAULT_ITEM_PADDING} -DHAVE_QT${QT_VERSION_MAJOR} -DHAVE_REPORT_DESIGNER -DUSE_QJSENGINE -D_CRT_SECURE_NO_WARNINGS) target_include_directories( ${PROJECT_NAME} PRIVATE - limereport/ - ${CMAKE_BINARY_DIR}/limereport + limereport/ limereport/base limereport/bands limereport/databrowser @@ -403,6 +469,9 @@ target_include_directories( ${PROJECT_NAME} PRIVATE limereport/serializators limereport/scripteditor ) +target_include_directories( ${PROJECT_NAME} PUBLIC + ${CMAKE_BINARY_DIR}/limereport ) + target_include_directories( ${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt new file mode 100644 index 0000000..aa6556f --- /dev/null +++ b/console/CMakeLists.txt @@ -0,0 +1,17 @@ +project(console) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +set(PROJECT_SOURCES + main.cpp +) + +add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES}) + +target_link_libraries(${PROJECT_NAME} PRIVATE + Qt${QT_VERSION_MAJOR}::Core + limereport-qt${QT_VERSION_MAJOR} +) + diff --git a/demo_r1/CMakeLists.txt b/demo_r1/CMakeLists.txt index 4f68d4a..dc7de6e 100644 --- a/demo_r1/CMakeLists.txt +++ b/demo_r1/CMakeLists.txt @@ -9,6 +9,7 @@ set(PROJECT_SOURCES mainwindow.cpp mainwindow.h mainwindow.ui + r1.qrc ) add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES}) diff --git a/demo_r2/CMakeLists.txt b/demo_r2/CMakeLists.txt new file mode 100644 index 0000000..09c2b9c --- /dev/null +++ b/demo_r2/CMakeLists.txt @@ -0,0 +1,25 @@ +project(demo_r2) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +set(PROJECT_SOURCES + main.cpp + mainwindow.cpp + mainwindow.h + mainwindow.ui + demo_r2.qrc +) + +add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES}) + +target_link_libraries(${PROJECT_NAME} PRIVATE + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::PrintSupport + Qt${QT_VERSION_MAJOR}::Qml + Qt${QT_VERSION_MAJOR}::Sql + limereport-qt${QT_VERSION_MAJOR} +) + diff --git a/limereport/dialogdesigner/lrdialogdesigner.cpp b/limereport/dialogdesigner/lrdialogdesigner.cpp index da1530c..7442c9e 100644 --- a/limereport/dialogdesigner/lrdialogdesigner.cpp +++ b/limereport/dialogdesigner/lrdialogdesigner.cpp @@ -1,7 +1,6 @@ #include "lrdialogdesigner.h" #include -#include #include #include #include @@ -14,7 +13,7 @@ #include #include -#if HAVE_QT5 +#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0)) #include #endif #if HAVE_QT4 diff --git a/limereport/lrfactoryinitializer.cpp b/limereport/lrfactoryinitializer.cpp index cae5eee..2a0ac0b 100644 --- a/limereport/lrfactoryinitializer.cpp +++ b/limereport/lrfactoryinitializer.cpp @@ -55,6 +55,8 @@ void initResources() Q_INIT_RESOURCE(items); Q_INIT_RESOURCE(lrscriptbrowser); Q_INIT_RESOURCE(translationeditor); +#endif +#ifdef ENABLE_DIALOG_DESIGNER Q_INIT_RESOURCE(dialogdesigner); #endif }