Skip to content

Commit

Permalink
CMake: Split Library and Plugin types into PROBE and UI; support BUIL…
Browse files Browse the repository at this point in the history
…D_SHARED_LIBS

User's choice of what's to be built is disambiguated from
how it's built. Both static and shared builds of both library
and plugins is now supported.
  • Loading branch information
Kentzo committed Jan 18, 2024
1 parent a929761 commit 13f7640
Show file tree
Hide file tree
Showing 42 changed files with 181 additions and 51 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/kde/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(gammaray_kitemmodels_srcs
kitemmodels_debug.cpp
)

add_library(gammaray_kitemmodels SHARED ${gammaray_kitemmodels_srcs})
add_library(gammaray_kitemmodels ${GAMMARAY_PROBE_LIBRARY_TYPE} ${gammaray_kitemmodels_srcs})

target_link_libraries(gammaray_kitemmodels PUBLIC Qt::Core)

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/kuserfeedback/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ list(APPEND gammaray_userfeedback_srcs
widgets/auditlogbrowserdialog.cpp
)

add_library(gammaray_kuserfeedback SHARED ${gammaray_userfeedback_srcs})
add_library(gammaray_kuserfeedback ${GAMMARAY_UI_LIBRARY_TYPE} ${gammaray_userfeedback_srcs})
# Disable warnings for generated stuff
if(MSVC)
set_source_files_properties(common/surveytargetexpressionlexer.cpp PROPERTIES COMPILE_FLAGS "/wd4018 /wd4996")
Expand Down
49 changes: 28 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,31 +222,36 @@ message(STATUS "Building GammaRay ${GAMMARAY_VERSION_STRING} in ${CMAKE_BUILD_TY
#
# Build options
#
set(GAMMARAY_BUILD_UI_DEFAULT ON)
if(QNXNTO OR ANDROID)
set(GAMMARAY_BUILD_UI_DEFAULT OFF)
option(BUILD_SHARED_LIBS "Build GammaRay statically or dynamically" ON)

set(GAMMARAY_STATIC_PROBE_DEFAULT OFF)
if(NOT BUILD_SHARED_LIBS)
set(GAMMARAY_STATIC_PROBE_DEFAULT ON)
endif()
gammaray_option(
GAMMARAY_STATIC_PROBE "Build the probe as static library for compile-time injection."
${GAMMARAY_STATIC_PROBE_DEFAULT}
)

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)
if(GAMMARAY_PROBE_ONLY_BUILD AND GAMMARAY_CLIENT_ONLY_BUILD)
message(FATAL_ERROR "You can only use one of the *ONLY* option.")
endif()

if(GAMMARAY_PROBE_ONLY_BUILD)
set(GAMMARAY_BUILD_UI_DEFAULT ON)
if(GAMMARAY_CLIENT_ONLY_BUILD)
set(GAMMARAY_BUILD_UI_DEFAULT ON)
elseif(GAMMARAY_PROBE_ONLY_BUILD)
set(GAMMARAY_BUILD_UI_DEFAULT OFF)
elseif(QNXNTO OR ANDROID)
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)
Expand All @@ -258,7 +263,6 @@ if(GAMMARAY_PROBE_ONLY_BUILD OR CMAKE_CROSSCOMPILING)
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)

Expand All @@ -267,15 +271,18 @@ gammaray_option(GAMMARAY_DISABLE_FEEDBACK "Disable user feedback support." ${GAM
#
# Static probe setup
#
if(GAMMARAY_STATIC_PROBE)
set(GAMMARAY_BUILD_UI OFF)
set(GAMMARAY_PROBE_ONLY_BUILD ON)
set(GAMMARAY_UI_LIBRARY_TYPE SHARED)
set(GAMMARAY_UI_PLUGIN_TYPE MODULE)
if(NOT BUILD_SHARED_LIBS)
set(GAMMARAY_UI_LIBRARY_TYPE STATIC)
set(GAMMARAY_UI_PLUGIN_TYPE STATIC)
endif()

set(GAMMARAY_LIBRARY_TYPE STATIC)
set(GAMMARAY_PLUGIN_TYPE STATIC)
else()
set(GAMMARAY_LIBRARY_TYPE SHARED)
set(GAMMARAY_PLUGIN_TYPE MODULE)
set(GAMMARAY_PROBE_LIBRARY_TYPE ${GAMMARAY_UI_LIBRARY_TYPE})
set(GAMMARAY_PROBE_PLUGIN_TYPE ${GAMMARAY_UI_PLUGIN_TYPE})
if(GAMMARAY_STATIC_PROBE)
set(GAMMARAY_PROBE_LIBRARY_TYPE STATIC)
set(GAMMARAY_PROBE_PLUGIN_TYPE STATIC)
endif()

gammaray_option(GAMMARAY_USE_PCH "Enable Precompiled Headers support" OFF)
Expand Down
6 changes: 4 additions & 2 deletions GammaRayConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ set(GAMMARAY_BUILD_UI @GAMMARAY_BUILD_UI@)
set(GAMMARAY_PROBE_ONLY_BUILD @GAMMARAY_PROBE_ONLY_BUILD@)

set(GAMMARAY_STATIC_PROBE @GAMMARAY_STATIC_PROBE@)
set(GAMMARAY_LIBRARY_TYPE @GAMMARAY_LIBRARY_TYPE@)
set(GAMMARAY_PLUGIN_TYPE @GAMMARAY_PLUGIN_TYPE@)
set(GAMMARAY_UI_LIBRARY_TYPE @GAMMARAY_UI_LIBRARY_TYPE@)
set(GAMMARAY_UI_PLUGIN_TYPE @GAMMARAY_UI_PLUGIN_TYPE@)
set(GAMMARAY_PROBE_LIBRARY_TYPE @GAMMARAY_PROBE_LIBRARY_TYPE@)
set(GAMMARAY_PROBE_PLUGIN_TYPE @GAMMARAY_PROBE_PLUGIN_TYPE@)
set(GAMMARAY_INSTALL_QT_LAYOUT @GAMMARAY_INSTALL_QT_LAYOUT@)

if(NOT GAMMARAY_OUTPUT_PREFIX)
Expand Down
4 changes: 2 additions & 2 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ elseif(WIN32)
endif()

add_library(
gammaray_client SHARED
${gammaray_clientlib_srcs}
gammaray_client
${GAMMARAY_UI_LIBRARY_TYPE} ${gammaray_clientlib_srcs}
)
generate_export_header(gammaray_client)
# cmake-lint: disable=E1120
Expand Down
11 changes: 9 additions & 2 deletions cmake/GammaRayMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include(CMakeParseArguments)
# - SOURCES <files> - the plugin sources
#
macro(gammaray_add_plugin _target_name)
set(oneValueArgs JSON)
set(oneValueArgs JSON TYPE)
set(multiValueArgs SOURCES)
cmake_parse_arguments(
_gammaray_add_plugin
Expand All @@ -27,12 +27,19 @@ macro(gammaray_add_plugin _target_name)
${ARGN}
)

set(_type_options UI PROBE)
if(NOT DEFINED _gammaray_add_plugin_TYPE)
set(_gammaray_add_plugin_TYPE PROBE)
elseif(NOT _gammaray_add_plugin_TYPE IN_LIST _type_options)
message(FATAL_ERROR "Plugin type must be either PROBE or UI")
endif()

if(NOT PROBE_PLUGIN_INSTALL_DIR) # HACK for external plugins that don't set PLUGIN_INSTALL_DIR
set(PROBE_PLUGIN_INSTALL_DIR ${GAMMARAY_PROBE_PLUGIN_INSTALL_DIR})
endif()
set(_build_target_dir "${GAMMARAY_OUTPUT_PREFIX}/${PROBE_PLUGIN_INSTALL_DIR}")

add_library(${_target_name} ${GAMMARAY_PLUGIN_TYPE} ${_gammaray_add_plugin_SOURCES})
add_library(${_target_name} ${GAMMARAY_${_gammaray_add_plugin_TYPE}_PLUGIN_TYPE} ${_gammaray_add_plugin_SOURCES})
set_target_properties(${_target_name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_build_target_dir})
set_target_properties(${_target_name} PROPERTIES PREFIX "")
if(GAMMARAY_STATIC_PROBE)
Expand Down
6 changes: 3 additions & 3 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ configure_file(
)

add_library(
gammaray_lz4 STATIC
gammaray_lz4 OBJECT
${CMAKE_SOURCE_DIR}/3rdparty/lz4/lz4.c
)
set_target_properties(gammaray_lz4 PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -80,7 +80,7 @@ set(gammaray_common_srcs

add_library(
gammaray_common
${GAMMARAY_LIBRARY_TYPE} ${gammaray_common_srcs}
${GAMMARAY_PROBE_LIBRARY_TYPE} ${gammaray_common_srcs}
)
generate_export_header(gammaray_common)
# cmake-lint: disable=E1120
Expand Down Expand Up @@ -144,7 +144,7 @@ set(gammaray_common_internal_srcs
)

add_library(
gammaray_common_internal STATIC
gammaray_common_internal OBJECT
${gammaray_common_internal_srcs}
)
set_target_properties(gammaray_common_internal PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ endif()
# core lib
add_library(
gammaray_core
${GAMMARAY_LIBRARY_TYPE} ${gammaray_srcs}
${GAMMARAY_PROBE_LIBRARY_TYPE} ${gammaray_srcs}
)
generate_export_header(gammaray_core)
target_compile_features(gammaray_core PUBLIC ${GAMMARAY_REQUIRED_CXX_FEATURES})
Expand Down
4 changes: 2 additions & 2 deletions launcher/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ else()
endif()

add_library(
gammaray_launcher SHARED
${gammaray_launcher_shared_srcs}
gammaray_launcher
${GAMMARAY_UI_LIBRARY_TYPE} ${gammaray_launcher_shared_srcs}
)
generate_export_header(gammaray_launcher)
# cmake-lint: disable=E1120
Expand Down
4 changes: 2 additions & 2 deletions launcher/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ else()
endif()

add_library(
gammaray_launcher_ui SHARED
${gammaray_launcher_ui_srcs}
gammaray_launcher_ui
${GAMMARAY_UI_LIBRARY_TYPE} ${gammaray_launcher_ui_srcs}
)
generate_export_header(gammaray_launcher_ui)
# cmake-lint: disable=E1120
Expand Down
4 changes: 4 additions & 0 deletions plugins/actioninspector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_actioninspector.json
SOURCES
${gammaray_actioninspector_plugin_srcs}
TYPE
PROBE
)

target_link_libraries(gammaray_actioninspector_plugin Qt::Gui Qt::Widgets gammaray_core)
Expand All @@ -41,6 +43,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_actioninspector.json
SOURCES
${gammaray_actioninspector_ui_plugin_srcs}
TYPE
UI
)

target_link_libraries(gammaray_actioninspector_ui_plugin gammaray_ui)
Expand Down
2 changes: 2 additions & 0 deletions plugins/bluetooth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
SOURCES
bluetooth.cpp
bluetooth.h
TYPE
PROBE
)
target_link_libraries(gammaray_bluetooth gammaray_core Qt::Bluetooth)
set_target_properties(gammaray_bluetooth PROPERTIES DISABLE_PRECOMPILE_HEADERS ON)
Expand Down
4 changes: 4 additions & 0 deletions plugins/codecbrowser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_codecbrowser.json
SOURCES
${gammaray_codecbrowser_plugin_srcs}
TYPE
PROBE
)
set_target_properties(gammaray_codecbrowser_plugin PROPERTIES DISABLE_PRECOMPILE_HEADERS ON)

Expand All @@ -34,6 +36,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_codecbrowser.json
SOURCES
${gammaray_codecbrowser_plugin_ui_srcs}
TYPE
UI
)

target_link_libraries(gammaray_codecbrowser_ui_plugin gammaray_common gammaray_ui)
Expand Down
4 changes: 4 additions & 0 deletions plugins/eventmonitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_eventmonitor.json
SOURCES
${gammaray_eventmonitor_plugin_srcs}
TYPE
PROBE
)

target_link_libraries(gammaray_eventmonitor_plugin Qt::Gui Qt::CorePrivate gammaray_core)
Expand All @@ -53,6 +55,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_eventmonitor.json
SOURCES
${gammaray_eventmonitor_ui_plugin_srcs}
TYPE
UI
)

target_link_libraries(gammaray_eventmonitor_ui_plugin gammaray_ui)
Expand Down
4 changes: 4 additions & 0 deletions plugins/fontbrowser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_fontbrowser.json
SOURCES
${gammaray_fontbrowser_plugin_srcs}
TYPE
PROBE
)

target_link_libraries(gammaray_fontbrowser_plugin gammaray_core)
Expand All @@ -52,6 +54,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_fontbrowser.json
SOURCES
${gammaray_fontbrowser_plugin_ui_srcs}
TYPE
UI
)

target_link_libraries(gammaray_fontbrowser_ui_plugin gammaray_common gammaray_ui)
Expand Down
4 changes: 4 additions & 0 deletions plugins/guisupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_guisupport.json
SOURCES
${gammaray_guisupport_srcs}
TYPE
PROBE
)
target_link_libraries(gammaray_guisupport gammaray_core Qt::Gui Qt::GuiPrivate)
endif()
Expand All @@ -31,6 +33,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_guisupport.json
SOURCES
${gammaray_guisupport_ui_srcs}
TYPE
UI
)
target_link_libraries(gammaray_guisupport_ui gammaray_ui)
endif()
4 changes: 4 additions & 0 deletions plugins/kjobtracker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_kjobtracker.json
SOURCES
${gammaray_kjob_plugin_srcs}
TYPE
PROBE
)

target_link_libraries(gammaray_kjobtracker_plugin gammaray_core KF${QtCore_VERSION_MAJOR}::CoreAddons Qt::Gui)
Expand All @@ -43,6 +45,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_kjobtracker.json
SOURCES
${gammaray_kjob_ui_plugin_srcs}
TYPE
UI
)

target_link_libraries(gammaray_kjobtracker_ui_plugin gammaray_ui)
Expand Down
4 changes: 4 additions & 0 deletions plugins/localeinspector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_localeinspector.json
SOURCES
${gammaray_localeinspector_plugin_srcs}
TYPE
PROBE
)
set_target_properties(gammaray_localeinspector_plugin PROPERTIES DISABLE_PRECOMPILE_HEADERS ON)

Expand Down Expand Up @@ -61,6 +63,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_localeinspector.json
SOURCES
${gammaray_localeinspector_plugin_ui_srcs}
TYPE
UI
)

target_link_libraries(gammaray_localeinspector_ui_plugin gammaray_ui)
Expand Down
4 changes: 4 additions & 0 deletions plugins/mimetypes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_mimetypes.json
SOURCES
${gammaray_mimetypes_srcs}
TYPE
PROBE
)
target_link_libraries(gammaray_mimetypes gammaray_core Qt::Gui gammaray_kitemmodels)
endif()
Expand All @@ -29,6 +31,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_mimetypes.json
SOURCES
${gammaray_mimetypes_ui_srcs}
TYPE
UI
)
target_link_libraries(gammaray_mimetypes_ui gammaray_ui)
endif()
4 changes: 4 additions & 0 deletions plugins/modelinspector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
gammaray_modelinspector.json
SOURCES
${gammaray_models_srcs}
TYPE
PROBE
)
set_target_properties(gammaray_modelinspector PROPERTIES DISABLE_PRECOMPILE_HEADERS ON)

Expand All @@ -56,6 +58,8 @@ if(GAMMARAY_BUILD_UI)
gammaray_modelinspector.json
SOURCES
${gammaray_models_ui_srcs}
TYPE
UI
)

target_link_libraries(gammaray_modelinspector_ui gammaray_ui)
Expand Down
Loading

0 comments on commit 13f7640

Please sign in to comment.