### Windows Qt Path Example Source: https://github.com/kdab/gammaray/blob/master/INSTALL.md Example of setting the CMAKE_PREFIX_PATH environment variable on Windows to specify the Qt installation. ```cmd set CMAKE_PREFIX_PATH=c:\Qt\6.6.0\msvc2019_64 cmake... ``` -------------------------------- ### Install API Documentation Source: https://github.com/kdab/gammaray/blob/master/docs/api/CMakeLists.txt Installs the generated gammaray-api.qch file to the specified QCH_INSTALL_DIR during the installation phase. ```cmake install( FILES ${DOXYGEN_OUTPUT_DIR}/qch/gammaray-api.qch DESTINATION ${QCH_INSTALL_DIR} ) ``` -------------------------------- ### Basic Build and Install Commands Source: https://github.com/kdab/gammaray/blob/master/INSTALL.md Standard commands to create a build directory, configure with CMake, build the project, and install it. Adapt the generator and install prefix as needed. ```bash mkdir build && cd build/ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/path/where/to/install .. cmake --build . cmake --build . --target install ``` -------------------------------- ### Install Probe Library (Default Layout) Source: https://github.com/kdab/gammaray/blob/master/probe/CMakeLists.txt Installs the gammaray_probe library to the specified destination when GAMMARAY_INSTALL_QT_LAYOUT is not set. Also handles installation of the Windows loader if applicable. ```cmake if(NOT GAMMARAY_INSTALL_QT_LAYOUT) set_target_properties(gammaray_probe PROPERTIES PREFIX "") gammaray_set_rpath(gammaray_probe ${PROBE_INSTALL_DIR}) install( TARGETS gammaray_probe EXPORT GammaRayTargets DESTINATION ${PROBE_INSTALL_DIR} ) if(WIN32) set_target_properties(gammaray_winloader PROPERTIES PREFIX "") install(TARGETS gammaray_winloader DESTINATION ${PROBE_INSTALL_DIR}) endif() else() set_target_properties(gammaray_probe PROPERTIES OUTPUT_NAME gammaray_probe-${GAMMARAY_PROBE_ABI}) gammaray_set_rpath(gammaray_probe ${LIB_INSTALL_DIR}) if(WIN32) set_target_properties(gammaray_winloader PROPERTIES OUTPUT_NAME gammaray_winloader-${GAMMARAY_PROBE_ABI}) install(TARGETS gammaray_winloader ${INSTALL_TARGETS_DEFAULT_ARGS}) endif() if(NOT GAMMARAY_PROBE_ONLY_BUILD) install( TARGETS gammaray_probe EXPORT GammaRayTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) ecm_generate_pri_file( BASE_NAME GammaRayProbe LIB_NAME gammaray_probe-${GAMMARAY_PROBE_ABI} DEPS "core gui network GammaRayCommon GammaRayCore" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR} ) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) else() install(TARGETS gammaray_probe ${INSTALL_TARGETS_DEFAULT_ARGS}) endif() if(ANDROID) install( FILES gammaray_probe-android-dependencies.xml RENAME gammaray_probe-${GAMMARAY_PROBE_ABI}_${ANDROID_ABI}-android-dependencies.xml DESTINATION ${LIB_INSTALL_DIR} ) endif() endif() if(MSVC) install( FILES "$/$""" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug RelWithDebInfo ) endif() endif() # GAMMARAY_CLIENT_ONLY_BUILD ``` -------------------------------- ### Install Launcher Executable Source: https://github.com/kdab/gammaray/blob/master/launcher/app/CMakeLists.txt Installs the `gammaray-launcher` executable to the specified destination directory. ```cmake install( TARGETS gammaray-launcher DESTINATION ${LIBEXEC_INSTALL_DIR} ) ``` -------------------------------- ### CMake Project Setup and Conan Integration Source: https://github.com/kdab/gammaray/blob/master/3rdparty/backward-cpp/test_package/CMakeLists.txt Configures the CMake project, includes Conan build information, and sets up targets for building an executable linked against Conan-managed libraries. Ensure Conan is installed and the build environment is set up correctly. ```cmake project(backward-package-test) cmake_minimum_required(VERSION 2.8) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) add_executable(example main.cpp) target_link_libraries(example PRIVATE ${CONAN_TARGETS}) ``` -------------------------------- ### Install libdwarf-dev for libdwarf Source: https://github.com/kdab/gammaray/blob/master/3rdparty/backward-cpp/README.md Install the libdwarf-dev package or its equivalent to use libdwarf for stack trace generation. ```bash apt-get install libdwarf-dev (or equivalent) ``` -------------------------------- ### Install Man Page Source: https://github.com/kdab/gammaray/blob/master/docs/man/CMakeLists.txt Installs the generated GammaRay man page to the specified installation directory. This ensures the man page is available after the project is installed. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gammaray.1 DESTINATION ${MAN_INSTALL_DIR}) ``` -------------------------------- ### Install PRI File Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Installs the generated .pri file to the specified ECM MKSPECS installation directory. ```cmake install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) ``` -------------------------------- ### Install libdw-dev for libdw Source: https://github.com/kdab/gammaray/blob/master/3rdparty/backward-cpp/README.md Install the libdw-dev package or its equivalent to use libdw for stack trace generation. ```bash apt-get install libdw-dev (or equivalent) ``` -------------------------------- ### Install binutils-dev for libbfd Source: https://github.com/kdab/gammaray/blob/master/3rdparty/backward-cpp/README.md Install the binutils-dev package or its equivalent to use libbfd for stack trace generation. ```bash apt-get install binutils-dev (or equivalent) ``` -------------------------------- ### Install GammaRay UI Headers Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Installs the public header files for the GammaRay UI module. ```cmake gammaray_install_headers( ${CMAKE_CURRENT_BINARY_DIR}/gammaray_ui_export.h clientdecorationidentityproxymodel.h clienttoolmanager.h propertyeditor/propertyeditordelegate.h propertywidget.h propertywidgettab.h tooluifactory.h uiintegration.h uistatemanager.h uiresources.h ) ``` -------------------------------- ### Install GammaRay UI Target Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Installs the gammaray_ui target with default arguments and exports it for use by other targets. ```cmake install( TARGETS gammaray_ui EXPORT GammaRayTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) ``` -------------------------------- ### Build Widget Layouting Example with CMake Source: https://github.com/kdab/gammaray/blob/master/examples/widget-layouting/CMakeLists.txt This CMakeLists.txt file defines an executable target 'example-widget-layouting' and links it with the Qt::Widgets library. It's used to build an application that demonstrates widget layouting. ```cmake set(widget_layouting_srcs widget-layouting.cpp) add_executable( example-widget-layouting ${widget_layouting_srcs} ) target_link_libraries( example-widget-layouting Qt::Widgets ) ``` -------------------------------- ### Install gammaray_inprocessui Target Source: https://github.com/kdab/gammaray/blob/master/inprocessui/CMakeLists.txt Installs the gammaray_inprocessui target to the specified destination directory. ```cmake install( TARGETS gammaray_inprocessui DESTINATION ${PROBE_PLUGIN_INSTALL_DIR} ) ``` -------------------------------- ### Program Startup Notice (Terminal) Source: https://github.com/kdab/gammaray/blob/master/LICENSES/LGPL-3.0-only.txt Include this notice in your program's output when it starts in interactive mode. It informs users about the warranty status and redistribution terms. ```text Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Version Setup (CMake) Source: https://github.com/kdab/gammaray/blob/master/CMakeLists.txt Sets up various version variables for the GammaRay project, including major, minor, patch, and full version strings, as well as shared library versions. ```cmake set(GAMMARAY_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(GAMMARAY_VERSION_MINOR ${PROJECT_VERSION_MINOR}) set(GAMMARAY_VERSION_PATCH ${PROJECT_VERSION_PATCH}) set(GAMMARAY_VERSION ${PROJECT_VERSION}) set(GAMMARAY_VERSION_STRING "${GAMMARAY_VERSION}") set(GAMMARAY_SOVERSION "${GAMMARAY_VERSION_MAJOR}.${GAMMARAY_VERSION_MINOR}.${GAMMARAY_VERSION_PATCH}") set(GAMMARAY_PLUGIN_VERSION "${GAMMARAY_VERSION_MAJOR}.${GAMMARAY_VERSION_MINOR}") set(PROJECT_VERSION_STRING "${GAMMARAY_VERSION_STRING}") ``` -------------------------------- ### Specify Qt Installation Path Source: https://github.com/kdab/gammaray/blob/master/INSTALL.md Use CMAKE_PREFIX_PATH to point CMake to a specific Qt installation directory when building GammaRay. ```bash cmake -DCMAKE_PREFIX_PATH=$HOME/Qt/6.6.0/gcc_64 .. ``` -------------------------------- ### Interactive Program Startup Notice Source: https://github.com/kdab/gammaray/blob/master/LICENSES/GPL-2.0-or-later.txt Display this notice when a program starts in interactive mode to inform users about its version, copyright, warranty status, and redistribution conditions. It directs users to specific commands for more details. ```text Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Add GammaRay Probe to Android Project Source: https://github.com/kdab/gammaray/blob/master/INSTALL.md Example of how to include the GammaRay probe in an Android project's .pro file. ```text myproject.pro .... android: QT += GammaRayProbe ... ``` -------------------------------- ### Probe-Only Build Configuration Source: https://github.com/kdab/gammaray/blob/master/INSTALL.md CMake options to build only the GammaRay probe for a new Qt version, installing it into an existing GammaRay prefix. ```bash cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/path/to/Qt/version/ \ -DGAMMARAY_PROBE_ONLY_BUILD=true \ -DGAMMARAY_BUILD_UI=false \ -DCMAKE_INSTALL_PREFIX=/path/to/your/previous/gammaray/prefix \ /path/to/gammaray/sources ``` -------------------------------- ### Generate PRI File for GammaRay UI Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Generates a .pri file for Qt's build system, specifying library name, dependencies, and installation directory. ```cmake ecm_generate_pri_file( BASE_NAME GammaRayUi LIB_NAME gammaray_ui-${GAMMARAY_PROBE_ABI} DEPS "core gui widgets GammaRayCommon" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR} ) ``` -------------------------------- ### Install App Icons on Unix-like Systems Source: https://github.com/kdab/gammaray/blob/master/ui/resources/CMakeLists.txt Installs GammaRay application icons in different sizes and scales to the Hicolor icon theme directory on Unix-like systems. This ensures the application has appropriate icons across various display densities. ```cmake if(UNIX AND NOT APPLE AND GAMMARAY_BUILD_UI ) foreach(size 16 24 32 48 64 128 256 512 ) foreach(scale 1 2 3) set(scaled_size ${size}x${size}) set(source gammaray/GammaRay-${scaled_size}.png) if(${scale} GREATER 1) set(scaled_size ${size}x${size}@${scale}) set(source gammaray/GammaRay-${scaled_size}x.png) endif() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source}) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/${source} DESTINATION "${ICON_INSTALL_DIR}/hicolor/${scaled_size}/apps" RENAME GammaRay.png ) endif() endforeach() endforeach() endif() ``` -------------------------------- ### Generate Binary Translation Files with Qt::lrelease Source: https://github.com/kdab/gammaray/blob/master/translations/CMakeLists.txt Sets up custom commands and targets to run `Qt::lrelease` for each language. This converts the `.ts` translation files into binary `.qm` files, which are used by Qt applications at runtime. The generated `.qm` files are installed. ```cmake foreach(lang ${LANGUAGES}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gammaray_${lang}.qm COMMAND Qt::lrelease ${CMAKE_CURRENT_SOURCE_DIR}/gammaray_${lang}.ts -qm ${CMAKE_CURRENT_BINARY_DIR}/gammaray_${lang}.qm DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gammaray_${lang}.ts COMMENT "Run lrelease to generate the translations for the specified language" ) add_custom_target( gammaray_${lang}_qm ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gammaray_${lang}.qm COMMENT "Target to generate the translations for specified language" ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gammaray_${lang}.qm DESTINATION ${TRANSLATION_INSTALL_DIR}) endforeach() ``` -------------------------------- ### Custom Target for Multibuild Installation Source: https://github.com/kdab/gammaray/blob/master/multibuild/CMakeLists.txt Defines a custom target 'multibuild_install' to manage the installation of the external GammaRay project. It ensures that the installation process is triggered correctly during the main build. ```cmake add_custom_target(multibuild_install COMMENT "Target for installing the multibuild version") add_dependencies(multibuild_install GammaRay-${_build_type}-install) _ep_get_step_stampfile(GammaRay-${_build_type} "install" install_stamp_file) if(install_stamp_file) install( CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E remove \"${install_stamp_file}\")" ) endif() install( CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target multibuild_install)" ) ``` -------------------------------- ### Conditional Installation for Probe-Only Build Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Installs the gammaray_ui target with default arguments only if not a probe-only build. ```cmake else() install(TARGETS gammaray_ui ${INSTALL_TARGETS_DEFAULT_ARGS}) endif() ``` -------------------------------- ### Applying LGPL to New Programs Source: https://github.com/kdab/gammaray/blob/master/LICENSES/LGPL-3.0-only.txt Use this template to add the necessary notices to your program's source files when applying the GNU General Public License. Ensure each file includes a copyright line and a pointer to the full notice. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Link Qt Widgets Library Source: https://github.com/kdab/gammaray/blob/master/examples/timer/CMakeLists.txt Links the 'example-timer' executable against the Qt::Widgets library. This ensures that Qt's widget functionalities are available to the application. ```cmake target_link_libraries( example-timer Qt::Widgets ) ``` -------------------------------- ### Install CMake Module Conditionally Source: https://github.com/kdab/gammaray/blob/master/cmake/CMakeLists.txt Installs the GammaRayMacros.cmake file to the CMake configuration directory only when the GAMMARAY_PROBE_ONLY_BUILD option is not enabled. ```cmake if(NOT GAMMARAY_PROBE_ONLY_BUILD) install(FILES GammaRayMacros.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) endif() ``` -------------------------------- ### Buildroot Configuration for GammaRay (Config.in) Source: https://github.com/kdab/gammaray/wiki/Cross-compiling-GammaRay This is the configuration file snippet for adding GammaRay to Buildroot. It defines the configuration option and its dependencies, primarily on BR2_PACKAGE_QT5. ```makefile config BR2_PACKAGE_GAMMARAY bool "gammaray" depends on BR2_PACKAGE_QT5 help GammaRay Qt introspection probe ``` -------------------------------- ### Install PDB Files on MSVC Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Installs PDB (Program Database) files for debugging on MSVC compiler in Debug and RelWithDebInfo configurations. ```cmake if(MSVC) install( FILES "$/$" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug RelWithDebInfo ) endif() ``` -------------------------------- ### Install PDB File on MSVC Source: https://github.com/kdab/gammaray/blob/master/inprocessui/CMakeLists.txt Conditionally installs the Program Database (PDB) file for the gammaray_inprocessui target on MSVC for Debug and RelWithDebInfo configurations. ```cmake if(MSVC) install( FILES "$/$" DESTINATION ${PROBE_PLUGIN_INSTALL_DIR} CONFIGURATIONS Debug RelWithDebInfo ) endif() ``` -------------------------------- ### Install macOS App Icon Source: https://github.com/kdab/gammaray/blob/master/ui/resources/CMakeLists.txt Installs the GammaRay application icon (.icns file) to the resources directory on macOS, unless a specific layout is disabled. ```cmake if(APPLE) if(NOT GAMMARAY_INSTALL_QT_LAYOUT) install(FILES gammaray/GammaRay.icns DESTINATION "${RESOURCES_INSTALL_DIR}") endif() endif() ``` -------------------------------- ### Link Libraries for Quick Material Test Source: https://github.com/kdab/gammaray/blob/master/tests/CMakeLists.txt Links the necessary Gammaray and Qt libraries to the quick material test target. Ensure Qt::Quick and Qt::QuickPrivate are available. ```cmake target_link_libraries(quickmaterialtest gammaray_core Qt::Quick Qt::QuickPrivate) ``` -------------------------------- ### Standard GPL Notice for Source Files Source: https://github.com/kdab/gammaray/blob/master/LICENSES/GPL-2.0-or-later.txt Include this notice at the beginning of each source file to clearly state copyright and licensing terms. It ensures the exclusion of warranty and points to the full license text. ```text one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. ``` -------------------------------- ### Set RPATH for gammaray_inprocessui Source: https://github.com/kdab/gammaray/blob/master/inprocessui/CMakeLists.txt Sets the RPATH for the gammaray_inprocessui target to the probe plugin installation directory. ```cmake gammaray_set_rpath(gammaray_inprocessui ${PROBE_PLUGIN_INSTALL_DIR}) ``` -------------------------------- ### Add QuickWidgetSupport Plugin Source: https://github.com/kdab/gammaray/blob/master/plugins/quickwidgetsupport/CMakeLists.txt Configures and adds the QuickWidgetSupport plugin to the GammaRay build. This snippet is conditional on GAMMARAY_CLIENT_ONLY_BUILD not being set. ```cmake if(NOT GAMMARAY_CLIENT_ONLY_BUILD) set(gammaray_quickwidgetsupport_srcs quickwidgetsupport.cpp quickwidgetsupport.h) gammaray_add_plugin( gammaray_quickwidgetsupport JSON gammaray_quickwidgetsupport.json SOURCES ${gammaray_quickwidgetsupport_srcs} ) target_link_libraries(gammaray_quickwidgetsupport gammaray_core Qt::QuickWidgets Qt::CorePrivate) endif() ``` -------------------------------- ### Configure Precompiled Headers Source: https://github.com/kdab/gammaray/blob/master/CMakeLists.txt Sets up a static library for precompiled headers if GAMMARAY_USE_PCH is enabled. Includes a dummy C++ file and links necessary Qt modules. ```cmake gammaray_option(GAMMARAY_USE_PCH "Enable Precompiled Headers support" OFF) if(GAMMARAY_USE_PCH) add_library(gammaray_pch_core_gui STATIC) file( GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp CONTENT "/*dummy pch file*/" ) target_sources(gammaray_pch_core_gui PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp) target_link_libraries(gammaray_pch_core_gui PRIVATE Qt::Core Qt::Gui) set_target_properties( gammaray_pch_core_gui PROPERTIES PRECOMPILE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/core/pch.h CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON ) endif() ``` -------------------------------- ### Ignore Optional Dependency Source: https://github.com/kdab/gammaray/blob/master/INSTALL.md Example of how to instruct CMake to ignore a specific optional dependency like VTK. ```bash cmake -DCMAKE_DISABLE_FIND_PACKAGE_VTK=True ``` -------------------------------- ### Define Include Directories for GammaRay UI Source: https://github.com/kdab/gammaray/blob/master/ui/CMakeLists.txt Sets include directories for the gammaray_ui target, distinguishing between build and install interfaces. ```cmake target_include_directories( gammaray_ui PUBLIC $ $ ) ``` -------------------------------- ### Define Executable and Source Files Source: https://github.com/kdab/gammaray/blob/master/examples/timer/CMakeLists.txt Defines the executable target 'example-timer' and specifies its source file 'timer.cpp'. This is a standard CMake command for building executables. ```cmake add_executable( example-timer timer.cpp ) ``` -------------------------------- ### Add Probe GUI Support Plugin Source: https://github.com/kdab/gammaray/blob/master/plugins/guisupport/CMakeLists.txt Configures the 'gammaray_guisupport' plugin, which provides core GUI support. It lists the source files and links necessary libraries like Qt::Gui and Qt::GuiPrivate. ```cmake if(NOT GAMMARAY_CLIENT_ONLY_BUILD) set(gammaray_guisupport_srcs guisupport.cpp guisupport.h ui.qrc) gammaray_add_plugin( gammaray_guisupport JSON gammaray_guisupport.json SOURCES ${gammaray_guisupport_srcs} ) target_link_libraries(gammaray_guisupport gammaray_core Qt::Gui Qt::GuiPrivate) endif() ``` -------------------------------- ### Add Translator Test Conditionally Source: https://github.com/kdab/gammaray/blob/master/tests/CMakeLists.txt Adds a probe test for translator functionality if the German translations are installed. Otherwise, it prints a warning. ```cmake if(NOT GAMMARAY_CLIENT_ONLY_BUILD) #does not work unless the translations are installed in QT_INSTALL_TRANSLATIONS if(EXISTS "${QT_INSTALL_TRANSLATIONS}/qtbase_de.qm") gammaray_add_probe_test(translatortest translatortest.cpp $) else() message(STATUS "WARNING: Skipping the translatortest since the translations are not installed.") endif() gammaray_add_probe_test(timertoptest timertoptest.cpp $) target_link_libraries(timertoptest gammaray_core Qt::Gui) if(TARGET Qt::Widgets) gammaray_add_probe_test(widgettest widgettest.cpp $) target_link_libraries(widgettest gammaray_core Qt::Widgets Qt::WidgetsPrivate) target_include_directories(widgettest PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/qt/5.5/) gammaray_add_probe_test( actiontest actiontest.cpp ${CMAKE_SOURCE_DIR}/plugins/actioninspector/clientactionmodel.cpp ) target_link_libraries(actiontest gammaray_core Qt::Widgets) endif() if(GAMMARAY_BUILD_UI) gammaray_add_probe_test( modelinspectortest modelinspectortest.cpp ${CMAKE_SOURCE_DIR}/plugins/modelinspector/modelinspectorinterface.cpp $ ) target_link_libraries(modelinspectortest gammaray_core gammaray_ui Qt::Gui) endif() if(TARGET Qt::Quick) gammaray_add_test( qmlsupporttest qmlsupporttest.cpp ${CMAKE_SOURCE_DIR}/plugins/qmlsupport/qmllistpropertyadaptor.cpp ${CMAKE_SOURCE_DIR}/plugins/qmlsupport/qmlattachedpropertyadaptor.cpp ${CMAKE_SOURCE_DIR}/plugins/qmlsupport/qjsvaluepropertyadaptor.cpp ${CMAKE_SOURCE_DIR}/plugins/qmlsupport/qmlcontextpropertyadaptor.cpp ) target_link_libraries(qmlsupporttest gammaray_core Qt::Quick Qt::QmlPrivate) endif() if(TARGET Qt::Quick) gammaray_add_quick_test(bindinginspectortest bindinginspectortest.cpp $) target_link_libraries(bindinginspectortest gammaray_core Qt::Quick Qt::QuickPrivate) target_sources( bindinginspectortest PUBLIC ${CMAKE_SOURCE_DIR}/plugins/quickinspector/quickimplicitbindingdependencyprovider.cpp ) target_sources(bindinginspectortest PUBLIC ${CMAKE_SOURCE_DIR}/plugins/qmlsupport/qmlbindingprovider.cpp) endif() if(TARGET Qt::Quick) gammaray_add_quick_test( quickinspectortest quickinspectortest.cpp quickinspectortest.qrc $ ) target_link_libraries( quickinspectortest gammaray_core gammaray_quickinspector_shared Qt::Quick Qt::QuickPrivate ) # only opengl rhi backend is supported atm if(${QT_VERSION_MAJOR} EQUAL 6 AND TARGET Qt6::Quick) set_tests_properties( quickinspectortest PROPERTIES ENVIRONMENT "QT_QUICK_BACKEND=rhi;QSG_RHI_BACKEND=opengl" ) endif() gammaray_add_quick_test( quickinspectortest2 quickinspectortest2.cpp quickinspectortest.qrc $ ) target_link_libraries(quickinspectortest2 gammaray_core gammaray_quickinspector_shared Qt::Quick) if(${QT_VERSION_MAJOR} EQUAL 6 AND TARGET Qt6::Quick) set_tests_properties( quickinspectortest2 PROPERTIES ENVIRONMENT "QT_QUICK_BACKEND=rhi;QSG_RHI_BACKEND=opengl" ) endif() # sw renderer support is only available in Qt 5.9.3 or newer add_test(NAME quickinspectortest2_softwarecontext COMMAND quickinspectortest2) set_tests_properties( quickinspectortest2_softwarecontext PROPERTIES ENVIRONMENT "QT_QUICK_BACKEND=softwarecontext" ) add_test(NAME quickinspectortest_softwarecontext COMMAND quickinspectortest) set_tests_properties( quickinspectortest_softwarecontext PROPERTIES ENVIRONMENT "QT_QUICK_BACKEND=softwarecontext" ) gammaray_add_quick_test( quickinspectorpickingtest quickinspectorpickingtest.cpp quickinspectortest.qrc $ ) target_link_libraries(quickinspectorpickingtest gammaray_core Qt::Test Qt::Quick) gammaray_add_quick_test( quickinspectorbench quickinspectorbench.cpp ../plugins/quickinspector/quickitemmodel.cpp ) target_link_libraries(quickinspectorbench gammaray_core Qt::Test Qt::Quick) gammaray_add_quick_test(quicktexturetest quicktexturetest.cpp quickinspectortest.qrc) endif() endif() ``` -------------------------------- ### Add Executable and Link Libraries Source: https://github.com/kdab/gammaray/blob/master/tests/manual/CMakeLists.txt Defines the 'connectionstest' executable and links it against the Qt Core library. ```cmake add_executable( connectionstest connectionstest.cpp ) target_link_libraries( connectionstest Qt::Core ) ``` -------------------------------- ### Set Probe Library Output Directories Source: https://github.com/kdab/gammaray/blob/master/probe/CMakeLists.txt Configures the output directories for the gammaray_probe library on different platforms. Ensures libraries are placed in the correct installation subdirectories. ```cmake set_target_properties( gammaray_probe PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${GAMMARAY_OUTPUT_PREFIX}/${PROBE_INSTALL_DIR}" RUNTIME_OUTPUT_DIRECTORY "${GAMMARAY_OUTPUT_PREFIX}/${PROBE_INSTALL_DIR}" ) target_compile_features(gammaray_probe PUBLIC ${GAMMARAY_REQUIRED_CXX_FEATURES}) ``` -------------------------------- ### Set CMake Output Directories Source: https://github.com/kdab/gammaray/blob/master/tests/targets/CMakeLists.txt Configures the output directories for runtime and library files for test executables. This helps in testing GammaRay when installed in different locations. ```cmake set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/testbin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/testlib) ``` -------------------------------- ### Add Executable and Link Libraries Source: https://github.com/kdab/gammaray/blob/master/tests/manual/CMakeLists.txt Defines the 'objectreparenttest' executable and links it against the Qt Core library. ```cmake add_executable( objectreparenttest objectreparenttest.cpp ) target_link_libraries( objectreparenttest Qt::Core ) ``` -------------------------------- ### Add Quick Test Executable Source: https://github.com/kdab/gammaray/blob/master/tests/CMakeLists.txt Defines an executable for quick tests, linking against probe, test helpers, and base test objects. It also sets the runtime path and links QtTest. ```cmake function(gammaray_add_quick_test _name) add_executable( ${_name} ${ARGN} $ $ $ $ ) gammaray_set_rpath(${_name} ${BIN_INSTALL_DIR}) target_link_libraries(${_name} $ Qt::Test) add_test(NAME ${_name} COMMAND ${_name}) endfunction() ``` -------------------------------- ### Add GeoPositionInfoSource Plugin Source: https://github.com/kdab/gammaray/blob/master/plugins/positioning/CMakeLists.txt Defines and installs the 'gammaray_geopositioninfosource' module, which acts as a proxy for geo position info source factories. This is added when not in client-only build mode. ```cmake set(gammaray_geopositioninfosource_srcs geopositioninfosource.cpp geopositioninfosource.h geopositioninfosourcefactory.cpp geopositioninfosourcefactory.h positioninginterface.cpp positioninginterface.h ) add_library(gammaray_geopositioninfosource MODULE ${gammaray_geopositioninfosource_srcs}) target_compile_features(gammaray_geopositioninfosource PUBLIC ${GAMMARAY_REQUIRED_CXX_FEATURES}) target_link_libraries(gammaray_geopositioninfosource gammaray_common Qt::Positioning Qt::CorePrivate) install(TARGETS gammaray_geopositioninfosource DESTINATION ${TARGET_PLUGIN_INSTALL_DIR}/position) ``` -------------------------------- ### Add Executable and Link Libraries Source: https://github.com/kdab/gammaray/blob/master/tests/manual/CMakeLists.txt Defines the 'signalmonitortest' executable and links it against Qt Core and Gui libraries. ```cmake add_executable( signalmonitortest signalmonitortest.cpp ) target_link_libraries( signalmonitortest Qt::Core Qt::Gui ) ``` -------------------------------- ### Find Qt Core Documentation Tags Source: https://github.com/kdab/gammaray/blob/master/docs/api/CMakeLists.txt Locates the qtcore.tags file, which is necessary for Doxygen to cross-reference Qt documentation. It searches in standard Qt documentation installation paths. ```cmake find_file(QDOC_QTCORE_TAG qtcore.tags HINTS ${QT_INSTALL_DOCS}/qtcore ${QT_INSTALL_DATA}/doc/qtcore) if(QDOC_QTCORE_TAG) get_filename_component(QDOC_TAG_DIR ${QDOC_QTCORE_TAG} DIRECTORY) get_filename_component(QDOC_TAG_DIR ${QDOC_TAG_DIR} DIRECTORY) endif() ``` -------------------------------- ### Find Backward with a package manager in CMake Source: https://github.com/kdab/gammaray/blob/master/3rdparty/backward-cpp/README.md Finds and links backward-cpp in your CMake project when installed via a package manager. This utilizes CMake's imported target mechanism. ```cmake find_package(Backward) # This will add libraries, definitions and include directories needed by backward # through an IMPORTED target. target_link_libraries(mytarget PUBLIC Backward::Backward) ``` -------------------------------- ### Define Launcher UI Sources Source: https://github.com/kdab/gammaray/blob/master/launcher/app/CMakeLists.txt Sets the source files for the GammaRay launcher's user interface. ```cmake set(gammaray_launcher_ui_srcs main.cpp ${CMAKE_SOURCE_DIR}/resources/gammaray.qrc) ``` -------------------------------- ### Link Libraries for Launcher Source: https://github.com/kdab/gammaray/blob/master/launcher/app/CMakeLists.txt Links the necessary Qt modules and custom GammaRay libraries to the `gammaray-launcher` target. ```cmake target_link_libraries( gammaray-launcher Qt::Gui Qt::Widgets gammaray_common gammaray_launcher_ui ) ``` -------------------------------- ### Generate API Documentation (.qch) Source: https://github.com/kdab/gammaray/blob/master/docs/api/CMakeLists.txt Defines a custom command to generate the gammaray-api.qch file using Doxygen. This command also includes steps to create directories and copy necessary license and PDF files. ```cmake add_custom_command( OUTPUT ${DOXYGEN_OUTPUT_DIR}/qch/gammaray-api.qch COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile #copy some files by-hand that are referred to by the markdown README COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIR}/html/LICENSES COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/LICENSES/GPL-2.0-or-later.txt ${DOXYGEN_OUTPUT_DIR}/html/LICENSES COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIR}/html/docs COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/docs/GammaRay-CopyrightAssignmentForm.pdf ${DOXYGEN_OUTPUT_DIR}/html/docs DEPENDS ${_all_hdrs} ${_dox_deps} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Generate the .qch file" ) ``` -------------------------------- ### Add Definitions for QNXNTO Source: https://github.com/kdab/gammaray/blob/master/CMakeLists.txt Adds the _QNX_SOURCE preprocessor definition when building on QNX Neutrino. ```cmake if(QNXNTO) add_definitions(-D_QNX_SOURCE) endif() ``` -------------------------------- ### Manual CMake Cross-compilation for Raspberry Pi Source: https://github.com/kdab/gammaray/wiki/Cross-compiling-GammaRay Use this CMake invocation for building the GammaRay probe for Raspberry Pi. Ensure the SYSROOT and PATH environment variables are correctly set, and the toolchain file path is accurate. Adjust CMAKE_PREFIX_PATH to your Qt installation within the sysroot. ```bash export SYSROOT=/where/your/rpi/sysroot/is/located export PATH=:$PATH cd cmake -DCMAKE_TOOLCHAIN_FILE=/cmake/Toolchain-RPI.cmake -DCMAKE_PREFIX_PATH=$SYSROOT/usr/local/Qt-5.5.1 -DCMAKE_INSTALL_PREFIX=$SYSROOT/usr/ -DGAMMARAY_BUILD_UI=OFF ``` -------------------------------- ### Customizable Build Options (CMake) Source: https://github.com/kdab/gammaray/blob/master/CMakeLists.txt Defines several boolean options using a custom `gammaray_option` macro to control build features. These include probe-only builds, client-only builds, UI, installation layout, multi-build support, CLI injector, State Machine UI, documentation, static probe, QT asserts, and feedback disabling. ```cmake gammaray_option( GAMMARAY_PROBE_ONLY_BUILD "Build only an additional probe configuration for an already existing launcher." OFF ) gammaray_option(GAMMARAY_CLIENT_ONLY_BUILD "Build the client part only." OFF) if(GAMMARAY_CLIENT_ONLY_BUILD) set(GAMMARAY_BUILD_UI_DEFAULT ON) endif() if(GAMMARAY_PROBE_ONLY_BUILD) set(GAMMARAY_BUILD_UI_DEFAULT OFF) endif() gammaray_option(GAMMARAY_BUILD_UI "Build the GammaRay client and in-process UI." ${GAMMARAY_BUILD_UI_DEFAULT}) if(GAMMARAY_PROBE_ONLY_BUILD AND GAMMARAY_CLIENT_ONLY_BUILD) message(FATAL_ERROR "You can only use one of the *ONLY* option.") endif() gammaray_option(GAMMARAY_INSTALL_QT_LAYOUT "Install into Qt directory layout." OFF) gammaray_option(GAMMARAY_MULTI_BUILD "Build multiple applicable probe configurations." ON) gammaray_option(GAMMARAY_BUILD_CLI_INJECTOR "Build command line injector on Windows." ON) gammaray_option(GAMMARAY_WITH_KDSME "Enable State Machine UI with KDSME" OFF) set(GAMMARAY_BUILD_DOCS_DEFAULT ON) set(GAMMARAY_DISABLE_FEEDBACK_DEFAULT OFF) if(GAMMARAY_PROBE_ONLY_BUILD OR CMAKE_CROSSCOMPILING) set(GAMMARAY_BUILD_DOCS_DEFAULT OFF) set(GAMMARAY_DISABLE_FEEDBACK_DEFAULT ON) endif() gammaray_option(GAMMARAY_BUILD_DOCS "Build GammaRay documentation." ${GAMMARAY_BUILD_DOCS_DEFAULT}) gammaray_option(GAMMARAY_STATIC_PROBE "Build the probe as static library for compile-time injection." OFF) gammaray_option(GAMMARAY_ENFORCE_QT_ASSERTS "Force QT_ASSERT in all builds." OFF) gammaray_option(GAMMARAY_DISABLE_FEEDBACK "Disable user feedback support." ${GAMMARAY_DISABLE_FEEDBACK_DEFAULT}) gammaray_option(WARNINGS_ARE_ERRORS "Enables -Werror" OFF) ``` -------------------------------- ### Add Executable and Link Libraries for QuickWidgets Test Source: https://github.com/kdab/gammaray/blob/master/tests/manual/CMakeLists.txt Defines the 'quickwidgettest' executable, including its resources, and links it against the Qt QuickWidgets module. This is for testing Qt Quick integration with QtWidgets. ```cmake if(TARGET Qt::QuickWidgets) set(quickwidgettest_srcs quickwidgettest.cpp quickwidgettest.qrc) add_executable(quickwidgettest ${quickwidgettest_srcs}) target_link_libraries(quickwidgettest Qt::QuickWidgets) endif() ``` -------------------------------- ### Add Executable and Link Libraries Source: https://github.com/kdab/gammaray/blob/master/tests/manual/CMakeLists.txt Defines the 'propertytest' executable and links it against Qt Core and GammaRay's shared test data library. ```cmake add_executable( propertytest propertytest.cpp ) target_link_libraries( propertytest Qt::Core gammaray_shared_test_data ) ``` -------------------------------- ### Create Intermediate Base Quick Test Object Library Source: https://github.com/kdab/gammaray/blob/master/tests/CMakeLists.txt Defines an intermediate OBJECT library for base Quick tests. This is compiled if Qt::Quick is available and includes Quick-specific definitions and directories. ```cmake add_library(base_quick_test_obj OBJECT basequicktest.h) set_target_properties(base_quick_test_obj PROPERTIES POSITION_INDEPENDENT_CODE ON) target_compile_features(base_quick_test_obj PUBLIC ${GAMMARAY_REQUIRED_CXX_FEATURES}) target_compile_definitions( base_quick_test_obj PRIVATE $ $ $ ) # for -DQT_NAMESPACE=... target_include_directories( base_quick_test_obj PUBLIC $ ) target_include_directories( base_quick_test_obj SYSTEM PUBLIC $ ) ``` -------------------------------- ### Create Launcher Executable Source: https://github.com/kdab/gammaray/blob/master/launcher/app/CMakeLists.txt Defines the `gammaray-launcher` executable, specifying it as a Windows application and including its source files. ```cmake add_executable( gammaray-launcher WIN32 ${gammaray_launcher_ui_srcs} ) ``` -------------------------------- ### Add Positioning UI Plugin Source: https://github.com/kdab/gammaray/blob/master/plugins/positioning/CMakeLists.txt Configures the 'gammaray_positioning_ui' plugin, which is built only if GAMMARAY_BUILD_UI is enabled and Qt Location and QuickWidgets targets are available. It includes UI-specific sources and links against GammaRay UI and Qt modules. ```cmake set(gammaray_positioning_ui_srcs mapcontroller.cpp mapcontroller.h positioningclient.cpp positioningclient.h positioninginterface.cpp positioninginterface.h positioningwidget.cpp positioningwidget.h positioningwidget.qrc ) # FIXME: make it work with Qt 6.5+ if(NOT QtCore_VERSION VERSION_GREATER_EQUAL 6.5) qml_lint(mapview.qml) endif() gammaray_add_plugin( gammaray_positioning_ui JSON gammaray_positioning.json SOURCES ${gammaray_positioning_ui_srcs} ) target_link_libraries( gammaray_positioning_ui gammaray_ui Qt::Widgets Qt::Positioning Qt::Location Qt::QuickWidgets ) ```