aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-24 18:23:32 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-25 10:12:36 +0100
commit38e3a2e587796df133f50363e65a68ec7989cb9b (patch)
treeaa0642e4f82ee0ba9a88ef8a0e56c527a643e0c7 /CMakeLists.txt
downloadBobinkQtOpcUaAppTemplate-38e3a2e587796df133f50363e65a68ec7989cb9b.tar.gz
BobinkQtOpcUaAppTemplate-38e3a2e587796df133f50363e65a68ec7989cb9b.zip
Initial commit: BobinkQtOpcUa app template with demo UI
Qt 6 QML application template using BobinkQtOpcUa as a submodule for OPC UA connectivity. Includes discovery, PKI, auth, node monitoring with read/write, and a multi-page demo UI.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt47
1 files changed, 47 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..b464cce
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 3.16)
+project(BobinkQtOpcUaAppTemplate LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# ── Qt setup (must come before BobinkQtOpcUa so AUTOMOC is enabled) ───────
+find_package(Qt6 6.10.2 REQUIRED COMPONENTS Quick)
+qt_standard_project_setup(REQUIRES 6.10.2)
+
+# ── 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).
+#
+# 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)
+
+qt_add_executable(BobinkQtOpcUaAppTemplate main.cpp)
+qt_add_qml_module(BobinkQtOpcUaAppTemplate URI BobinkQtOpcUaAppTemplate VERSION 1.0 QML_FILES Main.qml NodePage.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")
+
+# 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:
+
+# 1. 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")