2026-07-08 13:26:08 +08:00
# GammaRay MCP Bridge
2026-07-06 20:32:47 +08:00
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Links GammaRay client libs (GPL-2.0-or-later) => this bridge must be
2026-07-08 14:28:43 +08:00
# GPL-compatible. qtmcp is triple-licensed (LGPL-3.0-only / GPL-2.0-only /
# GPL-3.0-only); we comply under GPL-2.0-only.
2026-07-06 20:32:47 +08:00
cmake_minimum_required ( VERSION 3.16 )
2026-07-08 13:26:08 +08:00
project ( GammaRayMcpBridge LANGUAGES CXX )
2026-07-06 20:32:47 +08:00
set ( CMAKE_CXX_STANDARD 20 ) # qtmcp requires C++20
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( CMAKE_AUTOMOC ON )
# --- qtmcp via FetchContent FIRST ---
# qtmcp's find_package(Qt6) (inside the subdirectory) creates 3rd-party targets
# like Threads::Threads and promotes them to global THERE. If a prior top-level
# find_package(Qt6)/find_package(GammaRay) already created Threads::Threads at top
# scope, the subdirectory promotion fails ("not built in this directory"). So
# FetchContent runs before any Qt6/GammaRay find at this level.
include ( FetchContent )
FetchContent_Declare (
q t m c p
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / s i g n a l - s l o t / q t m c p . g i t
2026-07-07 23:43:48 +08:00
G I T _ T A G 2 7 0 6 3 4 5 c 4 4 e 2 8 2 a b a 1 5 c f 0 2 0 6 0 8 a f 2 2 8 3 e 9 f b 5 f 9
2026-07-06 20:32:47 +08:00
G I T _ S H A L L O W T R U E
2026-07-07 23:43:48 +08:00
G I T _ R E M O T E _ U P D A T E _ S T R A T E G Y C H E C K O U T
2026-07-06 20:32:47 +08:00
)
# Qt-prefixed vars (NOT BUILD_EXAMPLES) — verified to suppress example/test build.
set ( QT_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE )
set ( QT_BUILD_TESTS OFF CACHE BOOL "" FORCE )
2026-07-09 20:04:43 +08:00
# qtmcp is built as shared libs + plugins (Qt plugin system requires this).
# For a distribution deb, the package includes the qtmcp shared libs and
# stdio plugin alongside the bridge binary. CPACK_DEBIAN_PACKAGE_SHLIBDEPS
# auto-detects the required system dependencies (gammaray, qt6, etc.).
2026-07-06 20:32:47 +08:00
FetchContent_MakeAvailable ( qtmcp )
2026-07-09 20:04:43 +08:00
# --- GammaRay (system package: gammaray-dev >= 3.4.0) ---
2026-07-06 20:32:47 +08:00
find_package ( GammaRay REQUIRED )
# --- Qt6 components for the bridge target (Qt6 already found globally by qtmcp) ---
find_package ( Qt6 COMPONENTS Core Gui Widgets Network REQUIRED )
2026-07-08 13:26:08 +08:00
add_executable ( gammaray-mcp-bridge
2026-07-06 20:32:47 +08:00
s r c / m a i n . c p p
s r c / g a m m a r a y _ s e s s i o n . c p p
s r c / g a m m a r a y _ s e s s i o n . h
s r c / s c e n e g r a p h _ t o o l s . c p p
s r c / s c e n e g r a p h _ t o o l s . h
2026-07-07 16:48:44 +08:00
s r c / m a t e r i a l _ i n t e r f a c e . c p p
s r c / m a t e r i a l _ i n t e r f a c e . h
2026-07-07 23:43:48 +08:00
s r c / q u i c k i n s p e c t o r _ p r o x y . c p p
s r c / q u i c k i n s p e c t o r _ p r o x y . h
2026-07-07 16:48:44 +08:00
s r c / q u i c k i n s p e c t o r _ t y p e s . h
2026-07-08 13:09:00 +08:00
s r c / p r o p e r t y _ r e a d e r . c p p
s r c / p r o p e r t y _ r e a d e r . h
s r c / w i d g e t _ t o o l s . c p p
s r c / w i d g e t _ t o o l s . h
s r c / w i d g e t _ i n s p e c t o r _ p r o x y . c p p
s r c / w i d g e t _ i n s p e c t o r _ p r o x y . h
2026-07-06 20:32:47 +08:00
)
2026-07-08 13:26:08 +08:00
target_link_libraries ( gammaray-mcp-bridge PRIVATE
2026-07-06 20:32:47 +08:00
g a m m a r a y _ c l i e n t # VERIFIED: no GammaRay:: namespace
g a m m a r a y _ c o m m o n
Q t 6 : : C o r e
Q t 6 : : G u i
Q t 6 : : W i d g e t s # REQUIRED: QApplication for RemoteModel::style()
Q t 6 : : N e t w o r k
Q t 6 : : M c p S e r v e r # qtmcp, provides Qt::McpServer alias
Q t 6 : : M c p C o m m o n
)
2026-07-09 20:04:43 +08:00
install ( TARGETS gammaray-mcp-bridge RUNTIME DESTINATION bin )
install ( PROGRAMS run.sh DESTINATION bin )
2026-07-07 16:48:44 +08:00
2026-07-09 20:04:43 +08:00
# Runtime: qtmcp shared libs and stdio plugin are built in the build tree.
# For development, run.sh sets LD_LIBRARY_PATH and QT_PLUGIN_PATH.
# For distribution, CPack bundles qtmcp's install rules automatically.
2026-07-08 13:26:08 +08:00
set_target_properties ( gammaray-mcp-bridge PROPERTIES
2026-07-09 20:04:43 +08:00
B U I L D _ R P A T H " $ < T A R G E T _ F I L E _ D I R : Q t 6 : : M c p S e r v e r > "
I N S T A L L _ R P A T H " $ O R I G I N / . . / l i b / x 8 6 _ 6 4 - l i n u x - g n u "
2026-07-06 20:32:47 +08:00
)
2026-07-09 20:04:43 +08:00
# --- CPack packaging ---
set ( CPACK_PACKAGE_NAME "gammaray-mcp-bridge" )
set ( CPACK_PACKAGE_VERSION "0.1.0" )
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "GammaRay MCP bridge" )
set ( CPACK_PACKAGE_DESCRIPTION "MCP server that exposes GammaRay probe introspection data (QML SceneGraph, QML items, and Qt Widgets) to LLMs for assisted debugging." )
set ( CPACK_PACKAGE_CONTACT "Blumia <blumia@example.com>" )
set ( CPACK_PACKAGE_VENDOR "gammaray-mcp" )
set ( CPACK_PACKAGE_SECTION "devel" )
set ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Blumia <blumia@example.com>" )
set ( CPACK_DEBIAN_PACKAGE_SECTION "devel" )
set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/blumia/gammaray-mcp" )
set ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
set ( CPACK_DEBIAN_PACKAGE_RECOMMENDS "gammaray-plugin-quickinspector" )
set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" )
set ( CPACK_GENERATOR "DEB" )
include ( CPack )