-
Notifications
You must be signed in to change notification settings - Fork 32
Port to CMake #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Port to CMake #31
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| # - windows-latest | ||
| # - macos-15 | ||
|
|
||
| steps: | ||
| - name: Install Qt ${{ matrix.preset.qt_version }} | ||
| uses: jurplel/install-qt-action@v3 | ||
| with: | ||
| version: 5.15 | ||
| cache: true | ||
|
|
||
| - name: Install dependencies | ||
| if: ${{ runner.os == 'Linux' }} | ||
| run: | | ||
| sudo apt update -qq | ||
| sudo apt install xvfb | ||
|
|
||
| - name: Install ninja-build tool (must be after Qt due PATH changes) | ||
| uses: turtlesec-no/get-ninja@main | ||
|
|
||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Make sure MSVC is found when Ninja generator is in use | ||
| if: ${{ runner.os == 'Windows' }} | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
|
|
||
| - name: Build project (cmake) | ||
| run: | | ||
| cmake --preset=dev . | ||
| cmake --build build-dev | ||
|
|
||
| - name: Run tests (Linux) | ||
| if: ${{ runner.os == 'Linux' }} | ||
| run: xvfb-run ctest --test-dir ./build-dev --verbose | ||
| env: | ||
| DISPLAY: ":0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| cmake_minimum_required(VERSION 3.21) | ||
| project(declarativewidgets) | ||
|
|
||
| set(CMAKE_AUTOMOC ON) | ||
| set(CMAKE_AUTORCC ON) | ||
| set(CMAKE_AUTOUIC ON) | ||
| set(CMAKE_INCLUDE_CURRENT_DIRS ON) | ||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
|
|
||
| option(USE_QT6 "Use Qt6" OFF) | ||
| option(BUILD_EXAMPLES "Build the examples" ON) | ||
| option(ENABLE_SANITIZERS "Enable asan/ubsan sanitizers" OFF) | ||
|
|
||
| if(USE_QT6) | ||
| find_package(Qt6 6.5 NO_MODULE REQUIRED COMPONENTS Qml Widgets QuickWidgets) | ||
| find_package(Qt6 6.5 NO_MODULE QUIET COMPONENTS WebEngineWidgets) | ||
| set(QTMAJOR 6) | ||
| else() | ||
| find_package(Qt5 5.15 NO_MODULE REQUIRED COMPONENTS Qml Widgets QuickWidgets) | ||
| find_package(Qt5 5.15 NO_MODULE QUIET COMPONENTS WebEngineWidgets) | ||
| set(QTMAJOR 5) | ||
| endif() | ||
|
|
||
| if(ENABLE_SANITIZERS) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined") | ||
| set(CMAKE_EXE_LINKER_FLAGS | ||
| "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") | ||
| endif() | ||
|
|
||
| set(DW_PLUGIN_IMPORT_PATH \"${CMAKE_BINARY_DIR}/qml\") | ||
|
|
||
| add_executable(runner main.cpp) | ||
|
|
||
| target_compile_definitions( | ||
| runner PRIVATE -DPLUGIN_IMPORT_PATH=${DW_PLUGIN_IMPORT_PATH}) | ||
|
|
||
| target_link_libraries(runner PUBLIC Qt${QTMAJOR}::Qml Qt${QTMAJOR}::Widgets) | ||
|
|
||
| set_target_properties(runner PROPERTIES OUTPUT_NAME "declarativewidgets") | ||
|
|
||
| add_subdirectory(src) | ||
| add_subdirectory(ui2dw) | ||
| include(CTest) | ||
| if(BUILD_TESTING) | ||
| add_subdirectory(tests) | ||
| endif() | ||
|
|
||
| if(BUILD_EXAMPLES) | ||
| add_subdirectory(examples) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| { | ||
| "version": 2, | ||
| "configurePresets": [ | ||
| { | ||
| "name": "base", | ||
| "hidden": true, | ||
| "generator": "Ninja", | ||
| "binaryDir": "${sourceDir}/build-${presetName}", | ||
| "cacheVariables": { | ||
| "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
| "USE_QT6": "OFF" | ||
| } | ||
| }, | ||
| { | ||
| "name": "dev", | ||
| "inherits": "base", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "Debug", | ||
| "BUILD_TESTING": "ON" | ||
| } | ||
| }, | ||
| { | ||
| "name": "dev-asan", | ||
| "inherits": "dev", | ||
| "binaryDir": "${sourceDir}/build-${presetName}", | ||
| "cacheVariables": { | ||
| "ENABLE_SANITIZERS": "ON" | ||
| } | ||
| }, | ||
| { | ||
| "name": "rel", | ||
| "inherits": "base", | ||
| "binaryDir": "${sourceDir}/build-${presetName}", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "RelWithDebInfo", | ||
| "BUILD_TESTING": "OFF" | ||
| } | ||
| }, | ||
| { | ||
| "name": "dev6", | ||
| "inherits": "dev", | ||
| "binaryDir": "${sourceDir}/build-${presetName}", | ||
| "cacheVariables": { | ||
| "USE_QT6": "ON" | ||
| } | ||
| }, | ||
| { | ||
| "name": "rel6", | ||
| "inherits": "rel", | ||
| "binaryDir": "${sourceDir}/build-${presetName}", | ||
| "cacheVariables": { | ||
| "USE_QT6": "ON" | ||
| } | ||
| }, | ||
| { | ||
| "name": "dev-asan6", | ||
| "inherits": "dev6", | ||
| "binaryDir": "${sourceDir}/build-${presetName}", | ||
| "cacheVariables": { | ||
| "ENABLE_SANITIZERS": "ON" | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| if(USE_QT6) | ||
| find_package(Qt6 6.5 NO_MODULE REQUIRED COMPONENTS Sql QuickWidgets) | ||
iamsergio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else() | ||
| find_package(Qt5 5.15 NO_MODULE REQUIRED COMPONENTS Sql QuickWidgets) | ||
| endif() | ||
|
|
||
| add_subdirectory(bookstore) | ||
| add_subdirectory(config-editor) | ||
| add_subdirectory(text-editor) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| add_executable(bookstore main.cpp bookstore.cpp booksofauthormodel.cpp | ||
| booklistproxymodel.cpp bookstore.qrc) | ||
|
|
||
| target_link_libraries( | ||
| bookstore PRIVATE Qt${QTMAJOR}::Qml Qt${QTMAJOR}::Widgets | ||
| Qt${QTMAJOR}::QuickWidgets Qt${QTMAJOR}::Sql) | ||
|
|
||
| if(Qt${QTMAJOR}WebEngineWidgets_FOUND) | ||
| target_link_libraries(bookstore PRIVATE Qt${QTMAJOR}::WebEngineWidgets) | ||
| endif() | ||
|
|
||
| target_compile_definitions( | ||
| bookstore PRIVATE -DPLUGIN_IMPORT_PATH=${DW_PLUGIN_IMPORT_PATH}) | ||
|
|
||
| set(QML_FILES main.qml) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| add_executable(config-editor main.cpp configeditor.cpp settingsadaptor.cpp | ||
| config-editor.qrc) | ||
|
|
||
| target_link_libraries(config-editor PRIVATE Qt${QTMAJOR}::Qml | ||
| Qt${QTMAJOR}::Widgets) | ||
|
|
||
| if(Qt${QTMAJOR}WebEngineWidgets_FOUND) | ||
| target_link_libraries(config-editor PRIVATE Qt${QTMAJOR}::WebEngineWidgets) | ||
| endif() | ||
|
|
||
| target_compile_definitions( | ||
| config-editor PRIVATE -DPLUGIN_IMPORT_PATH=${DW_PLUGIN_IMPORT_PATH}) | ||
|
|
||
| set(QML_FILES main.qml) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| add_executable(text-editor main.cpp editor.cpp text-editor.qrc) | ||
|
|
||
| target_link_libraries(text-editor PRIVATE Qt${QTMAJOR}::Qml | ||
| Qt${QTMAJOR}::Widgets) | ||
|
|
||
| if(Qt${QTMAJOR}WebEngineWidgets_FOUND) | ||
| target_link_libraries(text-editor PRIVATE Qt${QTMAJOR}::WebEngineWidgets) | ||
| endif() | ||
|
|
||
| target_compile_definitions( | ||
| text-editor PRIVATE -DPLUGIN_IMPORT_PATH=${DW_PLUGIN_IMPORT_PATH}) | ||
|
|
||
| set(QML_FILES main.qml) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| set(TARGET declarativewidgets) | ||
|
|
||
| add_library( | ||
| ${TARGET} MODULE | ||
| abstractdeclarativeobject.cpp | ||
| declarativeaction.cpp | ||
| declarativeactionitem.cpp | ||
| declarativeboxlayout.cpp | ||
| declarativebuttongroupextension.cpp | ||
| declarativecolordialog.cpp | ||
| declarativecomboboxextension.cpp | ||
| declarativefiledialog.cpp | ||
| declarativefilesystemmodelextension.cpp | ||
| declarativefontdialog.cpp | ||
| declarativeformlayout.cpp | ||
| declarativegridlayout.cpp | ||
| declarativehboxlayout.cpp | ||
| declarativeicon.cpp | ||
| declarativeinputdialog.cpp | ||
| declarativeitemviewextension.cpp | ||
| declarativelabelextension.cpp | ||
| declarativelayoutextension.cpp | ||
| declarativeline.cpp | ||
| declarativeloaderwidget.cpp | ||
| declarativemessagebox.cpp | ||
| declarativeobjectextension.cpp | ||
| declarativepixmap.cpp | ||
| declarativeqmlcontext.cpp | ||
| declarativequickwidgetextension.cpp | ||
| declarativeseparator.cpp | ||
| declarativespaceritem.cpp | ||
| declarativestackedlayout.cpp | ||
| declarativestatusbar.cpp | ||
| declarativestringlistmodelextension.cpp | ||
| declarativetableviewextension.cpp | ||
| declarativetabstops.cpp | ||
| declarativetabwidget.cpp | ||
| declarativetexteditextension.cpp | ||
| declarativetreeviewextension.cpp | ||
| declarativevboxlayout.cpp | ||
| declarativewidgetextension.cpp | ||
| declarativewidgets_plugin.cpp | ||
| defaultobjectcontainer.cpp | ||
| defaultwidgetcontainer.cpp | ||
| mainwindowwidgetcontainer.cpp | ||
| menubarwidgetcontainer.cpp | ||
| menuwidgetcontainer.cpp | ||
| objectadaptors.cpp | ||
| scrollareawidgetcontainer.cpp | ||
| stackedwidgetwidgetcontainer.cpp | ||
| staticdialogmethodattached.cpp | ||
| toolbarwidgetcontainer.cpp | ||
| declarativesizepolicy.cpp) | ||
|
|
||
| target_link_libraries( | ||
| ${TARGET} | ||
| PRIVATE Qt${QTMAJOR}::Core Qt${QTMAJOR}::CorePrivate Qt${QTMAJOR}::Qml | ||
| Qt${QTMAJOR}::Widgets Qt${QTMAJOR}::QuickWidgets) | ||
|
|
||
| if(Qt${QTMAJOR}WebEngineWidgets_FOUND) | ||
| target_link_libraries(${TARGET} PRIVATE Qt${QTMAJOR}::WebEngineWidgets) | ||
| endif() | ||
|
|
||
| target_compile_definitions(${TARGET} PRIVATE BUILDING_DECLARATIVEWIDGETS) | ||
|
|
||
| set(PLUGIN_DESTDIR ${CMAKE_BINARY_DIR}/qml) | ||
|
|
||
| set_target_properties(${TARGET} PROPERTIES LIBRARY_OUTPUT_DIRECTORY | ||
| "${PLUGIN_DESTDIR}/QtWidgets") | ||
|
|
||
| if(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL "${PLUGIN_DESTDIR}/QtWidgets") | ||
| add_custom_command( | ||
| TARGET ${TARGET} | ||
| POST_BUILD | ||
| COMMENT "Copy qmldir to build directory" | ||
| COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir | ||
| ${PLUGIN_DESTDIR}/QtWidgets/qmldir) | ||
| endif() | ||
|
|
||
| install(TARGETS ${TARGET} | ||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/qt${QTMAJOR}/qml/QtWidgets) | ||
|
|
||
| install(FILES qmldir | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/qt${QTMAJOR}/qml/QtWidgets) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group | ||
| # company <info@kdab.com> | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| if(USE_QT6) | ||
| find_package(Qt6 6.5 NO_MODULE REQUIRED COMPONENTS Test Quick QuickWidgets) | ||
| else() | ||
| find_package(Qt5 5.15 NO_MODULE REQUIRED COMPONENTS Test Quick QuickWidgets) | ||
| endif() | ||
|
|
||
| enable_testing() | ||
| # Function to create a test executable with Qt dependencies Args: TEST_NAME: | ||
| # Name of the test executable to create ARGN: Additional source files for the | ||
| # test | ||
| function(add_test_executable test_name) | ||
| add_executable(${test_name} ${ARGN}) | ||
| add_test(NAME ${test_name} COMMAND ${test_name}) | ||
| target_link_libraries( | ||
| ${test_name} PRIVATE Qt${QTMAJOR}::Quick Qt${QTMAJOR}::Widgets | ||
| Qt${QTMAJOR}::QuickWidgets Qt${QTMAJOR}::Test) | ||
| if(Qt${QTMAJOR}WebEngineWidgets_FOUND) | ||
| target_link_libraries(${test_name} PRIVATE Qt${QTMAJOR}::WebEngineWidgets) | ||
| endif() | ||
| target_compile_definitions( | ||
| ${test_name} PRIVATE -DPLUGIN_IMPORT_PATH=${DW_PLUGIN_IMPORT_PATH}) | ||
| endfunction() | ||
|
|
||
| add_test_executable( | ||
| tst_instantiatetypes auto/instantiatetypes/tst_instantiatetypes.cpp | ||
| auto/instantiatetypes/qml.qrc) | ||
|
|
||
| add_test_executable( | ||
| tst_layouts | ||
| auto/layouts/formlayoutwidget.cpp | ||
| auto/layouts/gridlayoutwidget.cpp | ||
| auto/layouts/hboxlayoutwidget.cpp | ||
| auto/layouts/stackedlayoutwidget.cpp | ||
| auto/layouts/stackedwidget.cpp | ||
| auto/layouts/tst_layouts.cpp | ||
| auto/layouts/vboxlayoutwidget.cpp | ||
| auto/layouts/qml.qrc | ||
| auto/layouts/formlayout.ui | ||
| auto/layouts/gridlayout.ui | ||
| auto/layouts/hboxlayout.ui | ||
| auto/layouts/stackedwidget.ui | ||
| auto/layouts/vboxlayout.ui) | ||
|
|
||
| add_test_executable(tst_qmlplugins auto/qmlplugins/tst_qmlplugins.cpp) | ||
|
|
||
| add_test_executable(tst_quickwidget auto/quickwidget/tst_quickwidget.cpp | ||
| auto/quickwidget/quickwidgets.qrc) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.