Skip to content

Commit

Permalink
fixes for building examples with Qt6
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Kolesnykov <[email protected]>
  • Loading branch information
yurikoles committed Dec 14, 2022
1 parent 20d415b commit 1efeb1c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
10 changes: 8 additions & 2 deletions examples/books/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ get_filename_component(Grantlee_PLUGIN_DIR ${Grantlee_PLUGIN_DIR} PATH)

configure_file(grantlee_paths.h.cmake ${PROJECT_BINARY_DIR}/grantlee_paths.h)

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Sql REQUIRED)
if (GRANTLEE_BUILD_WITH_QT6)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Sql REQUIRED)
else()
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Sql REQUIRED)
endif()

add_executable(books
main.cpp
Expand All @@ -31,6 +36,7 @@ target_link_libraries(
books
Grantlee5::Templates
)

if (GRANTLEE_BUILD_WITH_QT6)
target_link_libraries(books
Qt6::Widgets
Expand Down
9 changes: 7 additions & 2 deletions examples/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ get_filename_component(Grantlee_PLUGIN_DIR ${Grantlee_PLUGIN_DIR} PATH)

configure_file(grantlee_paths.h.cmake ${PROJECT_BINARY_DIR}/grantlee_paths.h)

qt5_add_resources(
qt_add_resources(
codegen_example_RCS_SRCS
custom_tags.qrc
OPTIONS -root "/plugins/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}/"
Expand All @@ -35,12 +35,17 @@ add_executable(codegen
)
target_compile_definitions(codegen PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0)

find_package(Qt5Widgets REQUIRED)
if (GRANTLEE_BUILD_WITH_QT6)
find_package(Qt6Widgets REQUIRED)
else()
find_package(Qt5Widgets REQUIRED)
endif()

target_link_libraries(
codegen
Grantlee5::Templates
)

if (GRANTLEE_BUILD_WITH_QT6)
target_link_libraries(codegen
Qt6::Widgets
Expand Down
2 changes: 1 addition & 1 deletion examples/codegen/designwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DesignWidget : public QWidget
{
Q_OBJECT
public:
DesignWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
DesignWidget(QWidget *parent = 0, Qt::WindowFlags f = Qt::Widget);

Grantlee::Context getContext();

Expand Down
2 changes: 1 addition & 1 deletion examples/codegen/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Widget);
virtual ~MainWindow();

private Q_SLOTS:
Expand Down
4 changes: 2 additions & 2 deletions examples/contacts/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MainWindow : public QWidget
Q_OBJECT
public:
MainWindow(const QString &templateDir, QWidget *parent = 0,
Qt::WindowFlags f = 0);
Qt::WindowFlags f = Qt::Widget);

protected:
virtual void initLocalizer();
Expand All @@ -65,7 +65,7 @@ template <typename T> class AppMainWindow : public MainWindow
{
public:
AppMainWindow(const QString &templateDir, QWidget *parent = 0,
Qt::WindowFlags f = 0)
Qt::WindowFlags f = Qt::Widget)
: MainWindow(templateDir, parent, f)
{
}
Expand Down
23 changes: 14 additions & 9 deletions examples/textedit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ cmake_minimum_required(VERSION 3.5)
project(textedit_grantlee)

find_package(Grantlee5 REQUIRED)
find_package(Qt5Widgets REQUIRED)

if (GRANTLEE_BUILD_WITH_QT6)
find_package(Qt6Widgets REQUIRED)
else()
find_package(Qt5Widgets REQUIRED)
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -47,13 +52,13 @@ target_link_libraries(
)

if (GRANTLEE_BUILD_WITH_QT6)
target_link_libraries(
textedit
Qt6::Widgets
)
target_link_libraries(
textedit
Qt6::Widgets
)
else()
target_link_libraries(
textedit
Qt5::Widgets
)
target_link_libraries(
textedit
Qt5::Widgets
)
endif()

0 comments on commit 1efeb1c

Please sign in to comment.