0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Merge pull request #475 from xakod/feature/cmake_dialog_designer-update

cmake: add options ENABLE_DIALOG_DESIGNER and HAVE_UI_LOADER
This commit is contained in:
Alexander Arin 2024-10-23 15:30:27 +03:00 committed by GitHub
commit 33ebdfc640
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 126 additions and 13 deletions

View File

@ -9,22 +9,42 @@ set(DEFAULT_ITEM_PADDING 0)
option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF)
option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF)
option(LIMEREPORT_DEMO "Build LimeReport demos" 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) 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) if(USE_QT6)
find_package(QT NAMES Qt6) find_package(QT NAMES Qt6)
else() else()
find_package(QT NAMES Qt5) find_package(QT NAMES Qt5)
endif(USE_QT6) endif(USE_QT6)
find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS Core Widgets Sql Network Xml Svg Qml PrintSupport REQUIRED
)
find_package( find_package(
Qt${QT_VERSION_MAJOR} 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 # Old Qt does not provide QT_VERSION_MAJOR
if (NOT QT_VERSION_MAJOR) if (NOT QT_VERSION_MAJOR)
string(SUBSTRING ${QT_VERSION} 0 1 QT_VERSION_MAJOR) string(SUBSTRING ${QT_VERSION} 0 1 QT_VERSION_MAJOR)
@ -41,8 +61,10 @@ endif()
add_subdirectory(3rdparty) add_subdirectory(3rdparty)
if (LIMEREPORT_DEMO) if (LIMEREPORT_DEMO)
add_subdirectory(console)
add_subdirectory(designer) add_subdirectory(designer)
add_subdirectory(demo_r1) add_subdirectory(demo_r1)
add_subdirectory(demo_r2)
endif() endif()
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
@ -318,7 +340,6 @@ ${PROJECT_NAME}/translationeditor/translationeditor.ui
${PROJECT_NAME}/databrowser/lrdatabrowser.qrc ${PROJECT_NAME}/databrowser/lrdatabrowser.qrc
${PROJECT_NAME}/dialogdesigner/dialogdesigner.qrc
${PROJECT_NAME}/items/items.qrc ${PROJECT_NAME}/items/items.qrc
${PROJECT_NAME}/objectinspector/lobjectinspector.qrc ${PROJECT_NAME}/objectinspector/lobjectinspector.qrc
${PROJECT_NAME}/report.qrc ${PROJECT_NAME}/report.qrc
@ -326,6 +347,28 @@ ${PROJECT_NAME}/scriptbrowser/lrscriptbrowser.qrc
${PROJECT_NAME}/translationeditor/translationeditor.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) if (ENABLE_ZINT)
list(APPEND LIMEREPORT_SOURCES ${PROJECT_NAME}/items/lrbarcodeitem.cpp) list(APPEND LIMEREPORT_SOURCES ${PROJECT_NAME}/items/lrbarcodeitem.cpp)
list(APPEND LIMEREPORT_SOURCES ${PROJECT_NAME}/items/lrbarcodeitem.h) list(APPEND LIMEREPORT_SOURCES ${PROJECT_NAME}/items/lrbarcodeitem.h)
@ -369,11 +412,11 @@ else()
target_compile_definitions( ${PROJECT_NAME} INTERFACE -DLIMEREPORT_IMPORTS) target_compile_definitions( ${PROJECT_NAME} INTERFACE -DLIMEREPORT_IMPORTS)
endif() endif()
if(Qt${QT_VERSION_MAJOR}UiTools_FOUND) if(HAVE_UI_LOADER)
target_compile_definitions( ${PROJECT_NAME} PRIVATE -DHAVE_UI_LOADER) target_compile_definitions( ${PROJECT_NAME} PRIVATE -DHAVE_UI_LOADER)
target_link_libraries( ${PROJECT_NAME} PUBLIC target_link_libraries( ${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::UiTools) Qt${QT_VERSION_MAJOR}::UiTools)
endif() endif()
target_link_libraries( ${PROJECT_NAME} PUBLIC target_link_libraries( ${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Core
@ -384,6 +427,30 @@ target_link_libraries( ${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Svg) 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) if(ENABLE_ZINT)
target_link_libraries( ${PROJECT_NAME} PRIVATE QZint) target_link_libraries( ${PROJECT_NAME} PRIVATE QZint)
endif(ENABLE_ZINT) 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_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 target_include_directories( ${PROJECT_NAME} PRIVATE
limereport/ limereport/
${CMAKE_BINARY_DIR}/limereport
limereport/base limereport/base
limereport/bands limereport/bands
limereport/databrowser limereport/databrowser
@ -403,6 +469,9 @@ target_include_directories( ${PROJECT_NAME} PRIVATE
limereport/serializators limereport/serializators
limereport/scripteditor ) limereport/scripteditor )
target_include_directories( ${PROJECT_NAME} PUBLIC
${CMAKE_BINARY_DIR}/limereport )
target_include_directories( ${PROJECT_NAME} INTERFACE target_include_directories( ${PROJECT_NAME} INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include) ${CMAKE_CURRENT_SOURCE_DIR}/include)

17
console/CMakeLists.txt Normal file
View File

@ -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}
)

View File

@ -9,6 +9,7 @@ set(PROJECT_SOURCES
mainwindow.cpp mainwindow.cpp
mainwindow.h mainwindow.h
mainwindow.ui mainwindow.ui
r1.qrc
) )
add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES}) add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES})

25
demo_r2/CMakeLists.txt Normal file
View File

@ -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}
)

View File

@ -1,7 +1,6 @@
#include "lrdialogdesigner.h" #include "lrdialogdesigner.h"
#include <QAction> #include <QAction>
#include <QDebug>
#include <QDesignerActionEditorInterface> #include <QDesignerActionEditorInterface>
#include <QDesignerComponents> #include <QDesignerComponents>
#include <QDesignerFormEditorInterface> #include <QDesignerFormEditorInterface>
@ -14,7 +13,7 @@
#include <QPluginLoader> #include <QPluginLoader>
#include <QVBoxLayout> #include <QVBoxLayout>
#if HAVE_QT5 #if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0))
#include <QDesignerIntegration> #include <QDesignerIntegration>
#endif #endif
#if HAVE_QT4 #if HAVE_QT4

View File

@ -55,6 +55,8 @@ void initResources()
Q_INIT_RESOURCE(items); Q_INIT_RESOURCE(items);
Q_INIT_RESOURCE(lrscriptbrowser); Q_INIT_RESOURCE(lrscriptbrowser);
Q_INIT_RESOURCE(translationeditor); Q_INIT_RESOURCE(translationeditor);
#endif
#ifdef ENABLE_DIALOG_DESIGNER
Q_INIT_RESOURCE(dialogdesigner); Q_INIT_RESOURCE(dialogdesigner);
#endif #endif
} }