aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-26 12:46:01 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-26 12:46:01 +0100
commit78cd0db668657b78e73319d7653f217cf205d836 (patch)
tree188555ebfafa45ccc9e365661ea8db9a45b258bb /CMakeLists.txt
parent6b6c5f124516697cd1b94d48e63c81b582ce0568 (diff)
downloadBobinkQtOpcUaAppTemplate-78cd0db668657b78e73319d7653f217cf205d836.tar.gz
BobinkQtOpcUaAppTemplate-78cd0db668657b78e73319d7653f217cf205d836.zip
Bump BobinkQtOpcUa, add qmlls support, simplify template
- Update BobinkQtOpcUa submodule (qmlls + qmlformat support) - Enable QT_QML_GENERATE_QMLLS_INI and add IMPORT_PATH for QML Language Server integration - Remove NodePage.qml and simplify Main.qml to avoid duplicating the demo already provided in deps/BobinkQtOpcUa/demo - Add .qmlls.ini to .gitignore
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt66
1 files changed, 43 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b464cce..4b0403c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,40 +8,60 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.10.2 REQUIRED COMPONENTS Quick)
qt_standard_project_setup(REQUIRES 6.10.2)
+# ── QML tooling ────────────────────────────────────────────────────────────
+# Generate .qmlls.ini for QML Language Server
+set(QT_QML_GENERATE_QMLLS_INI
+ ON
+ CACHE BOOL "")
+
# ── BobinkQtOpcUa ──────────────────────────────────────────────────────────
-# Builds open62541 and QtOpcUa from submodules automatically on first
-# configure. Subsequent configures skip the dep builds (delete
-# build/deps/*-install/ to force a rebuild).
+# Builds open62541 and QtOpcUa from submodules automatically on first configure.
+# Subsequent configures skip the dep builds (delete build/deps/*-install/ to
+# force a rebuild).
#
-# Prerequisites: Qt 6.10.2+ with qt-cmake in PATH, OpenSSL dev headers,
-# Ninja, and initialized submodules:
-# git submodule update --init --recursive
+# Prerequisites: Qt 6.10.2+ with qt-cmake in PATH, OpenSSL dev headers, Ninja,
+# and initialized submodules: git submodule update --init --recursive
add_subdirectory(deps/BobinkQtOpcUa)
+# Ensure the qml/ import directory exists before qmlimportscanner runs
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/qml")
+
qt_add_executable(BobinkQtOpcUaAppTemplate main.cpp)
-qt_add_qml_module(BobinkQtOpcUaAppTemplate URI BobinkQtOpcUaAppTemplate VERSION 1.0 QML_FILES Main.qml NodePage.qml)
+qt_add_qml_module(
+ BobinkQtOpcUaAppTemplate
+ URI
+ BobinkQtOpcUaAppTemplate
+ VERSION
+ 1.0
+ QML_FILES
+ Main.qml
+ IMPORT_PATH
+ "${CMAKE_BINARY_DIR}/deps/BobinkQtOpcUa/qml")
# Executable goes to bin/ to avoid clashing with the QML module directory
-set_target_properties(BobinkQtOpcUaAppTemplate PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+set_target_properties(
+ BobinkQtOpcUaAppTemplate PROPERTIES RUNTIME_OUTPUT_DIRECTORY
+ "${CMAKE_BINARY_DIR}/bin")
-# Link against BobinkQtOpcUaplugin (not BobinkQtOpcUa). The "plugin"
-# target includes the QML type registration needed for `import Bobink`.
-target_link_libraries(BobinkQtOpcUaAppTemplate PRIVATE Qt6::Quick BobinkQtOpcUaplugin)
+# Link against BobinkQtOpcUaplugin (not BobinkQtOpcUa). The "plugin" target
+# includes the QML type registration needed for `import Bobink`.
+target_link_libraries(BobinkQtOpcUaAppTemplate PRIVATE Qt6::Quick
+ BobinkQtOpcUaplugin)
# ── Runtime quirks ──────────────────────────────────────────────────────────
-# BobinkQtOpcUa builds open62541 as a shared library. The QtOpcUa backend
-# plugin (loaded at runtime via dlopen) needs to find it. These two lines
-# make that work during development:
+# BobinkQtOpcUa builds open62541 as a shared library. The QtOpcUa backend plugin
+# (loaded at runtime via dlopen) needs to find it. These two lines make that
+# work during development:
-# 1. RPATH: embed the dep lib dirs so the dynamic linker finds libopen62541
-# and libQt6OpcUa at runtime without installing them system-wide.
+# RPATH: embed the dep lib dirs so the dynamic linker finds libopen62541 and
+# libQt6OpcUa at runtime without installing them system-wide.
set(CMAKE_BUILD_RPATH "${QTOPCUA_INSTALL_DIR}/lib"
"${OPEN62541_INSTALL_DIR}/lib")
-# 2. Plugin path: Qt's plugin loader doesn't know about our locally-built
-# QtOpcUa backend. Pass the path as a compile definition and call
-# QCoreApplication::addLibraryPath(QTOPCUA_PLUGIN_PATH) in main.cpp
-# *before* creating the QGuiApplication.
-target_compile_definitions(BobinkQtOpcUaAppTemplate PRIVATE
- QTOPCUA_PLUGIN_PATH="${QTOPCUA_INSTALL_DIR}/plugins")
+# Plugin path: Qt's plugin loader doesn't know about our locally-built QtOpcUa
+# backend. Pass the path as a compile definition and call
+# QCoreApplication::addLibraryPath(QTOPCUA_PLUGIN_PATH) in main.cpp *before*
+# creating the QGuiApplication.
+target_compile_definitions(
+ BobinkQtOpcUaAppTemplate
+ PRIVATE QTOPCUA_PLUGIN_PATH="${QTOPCUA_INSTALL_DIR}/plugins")