From 2c23dc01239054cdadd3ceae0c0cbab50bed9775 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 17 May 2021 18:43:37 +0200 Subject: [PATCH] Use more target-centric cmake code NO_CHANGELOG --- .../customDataContainers/CMakeLists.txt | 6 ++--- .../dataengines/simpleEngine/CMakeLists.txt | 6 +---- .../sourcesOnRequest/CMakeLists.txt | 6 +---- examples/shell/CMakeLists.txt | 9 +++---- .../CMakeLists.txt | 7 ++--- .../calendar/CMakeLists.txt | 6 ++--- src/declarativeimports/core/CMakeLists.txt | 9 ++++--- .../plasmacomponents/CMakeLists.txt | 5 ++-- .../plasmaextracomponents/CMakeLists.txt | 7 +++-- .../platformcomponents/CMakeLists.txt | 11 ++++---- src/plasma/CMakeLists.txt | 27 +++++++++---------- src/plasmaquick/CMakeLists.txt | 23 ++++++++-------- src/scriptengines/qml/CMakeLists.txt | 7 ++--- templates/cpp-plasmoid/src/CMakeLists.txt | 6 +---- .../plugin/CMakeLists.txt | 6 +---- .../plugin/CMakeLists.txt | 6 +---- 16 files changed, 62 insertions(+), 85 deletions(-) diff --git a/examples/dataengines/customDataContainers/CMakeLists.txt b/examples/dataengines/customDataContainers/CMakeLists.txt index 3ef869093..cee41e9be 100644 --- a/examples/dataengines/customDataContainers/CMakeLists.txt +++ b/examples/dataengines/customDataContainers/CMakeLists.txt @@ -1,10 +1,10 @@ -set(customDataContainers_SRCS +add_library(plasma_dataengine_example_customDataContainers MODULE) + +target_sources(plasma_dataengine_example_customDataContainers PRIVATE customDataContainersEngine.cpp httpContainer.cpp ) -add_library(plasma_dataengine_example_customDataContainers MODULE ${customDataContainers_SRCS}) - kcoreaddons_desktop_to_json(plasma_dataengine_example_customDataContainers plasma-dataengine-example-customDataContainers.desktop) target_link_libraries(plasma_dataengine_example_customDataContainers diff --git a/examples/dataengines/simpleEngine/CMakeLists.txt b/examples/dataengines/simpleEngine/CMakeLists.txt index 13fdf8e07..d733b54a0 100644 --- a/examples/dataengines/simpleEngine/CMakeLists.txt +++ b/examples/dataengines/simpleEngine/CMakeLists.txt @@ -1,8 +1,4 @@ -set(simpleEngine_SRCS - simpleEngine.cpp -) - -add_library(plasma_dataengine_example_simpleEngine MODULE ${simpleEngine_SRCS}) +add_library(plasma_dataengine_example_simpleEngine MODULE simpleEngine.cpp) kcoreaddons_desktop_to_json(plasma_dataengine_example_simpleEngine plasma-dataengine-example-simpleEngine.desktop) diff --git a/examples/dataengines/sourcesOnRequest/CMakeLists.txt b/examples/dataengines/sourcesOnRequest/CMakeLists.txt index aea248d2c..7c73f38b2 100644 --- a/examples/dataengines/sourcesOnRequest/CMakeLists.txt +++ b/examples/dataengines/sourcesOnRequest/CMakeLists.txt @@ -1,8 +1,4 @@ -set(sourcesOnRequest_SRCS - sourcesOnRequest.cpp -) - -add_library(plasma_dataengine_example_sourcesOnRequest MODULE ${sourcesOnRequest_SRCS}) +add_library(plasma_dataengine_example_sourcesOnRequest MODULE sourcesOnRequest.cpp) kcoreaddons_desktop_to_json(plasma_dataengine_example_sourcesOnRequest plasma-dataengine-example-sourcesOnRequest.desktop) diff --git a/examples/shell/CMakeLists.txt b/examples/shell/CMakeLists.txt index 7799d32ae..1d5c8ba36 100644 --- a/examples/shell/CMakeLists.txt +++ b/examples/shell/CMakeLists.txt @@ -1,12 +1,11 @@ -set(exampleplasmashell-app_SRCS +add_executable(exampleplasmashell) + +target_sources(exampleplasmashell PRIVATE customcorona.cpp main.cpp ) -add_executable(exampleplasmashell ${exampleplasmashell-app_SRCS}) - -target_link_libraries( - exampleplasmashell +target_link_libraries(exampleplasmashell Qt5::Widgets Qt5::Quick Qt5::Qml diff --git a/examples/testcontainmentactionsplugin/CMakeLists.txt b/examples/testcontainmentactionsplugin/CMakeLists.txt index 62d649714..ee754a85a 100644 --- a/examples/testcontainmentactionsplugin/CMakeLists.txt +++ b/examples/testcontainmentactionsplugin/CMakeLists.txt @@ -1,9 +1,6 @@ -set(test_SRCS - test.cpp -) -ki18n_wrap_ui(test_SRCS config.ui) +add_library(plasma_containmentactions_test MODULE test.cpp) +ki18n_wrap_ui(plasma_containmentactions_test config.ui) -add_library(plasma_containmentactions_test MODULE ${test_SRCS}) target_link_libraries(plasma_containmentactions_test KF5::Plasma KF5::I18n KF5::KIOWidgets KF5::XmlGui) install(TARGETS plasma_containmentactions_test DESTINATION ${KDE_INSTALL_PLUGINDIR}) diff --git a/src/declarativeimports/calendar/CMakeLists.txt b/src/declarativeimports/calendar/CMakeLists.txt index 9316419cb..a25076047 100644 --- a/src/declarativeimports/calendar/CMakeLists.txt +++ b/src/declarativeimports/calendar/CMakeLists.txt @@ -1,4 +1,6 @@ -set(calendar_SRCS +add_library(calendarplugin SHARED) + +target_sources(calendarplugin PRIVATE calendarplugin.cpp #incidencemodifier.cpp calendar.cpp @@ -11,8 +13,6 @@ set(calendar_SRCS eventpluginsmanager.cpp ) -add_library(calendarplugin SHARED ${calendar_SRCS}) - target_link_libraries(calendarplugin Qt5::Core Qt5::Quick diff --git a/src/declarativeimports/core/CMakeLists.txt b/src/declarativeimports/core/CMakeLists.txt index df0023921..c95b4b441 100644 --- a/src/declarativeimports/core/CMakeLists.txt +++ b/src/declarativeimports/core/CMakeLists.txt @@ -6,7 +6,9 @@ endif() configure_file(config-x11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-x11.h) -set(corebindings_SRCS +add_library(corebindingsplugin SHARED) + +target_sources(corebindingsplugin PRIVATE corebindingsplugin.cpp colorscope.cpp datamodel.cpp @@ -22,11 +24,10 @@ set(corebindings_SRCS iconitem.cpp units.cpp windowthumbnail.cpp - ) -qt_add_resources(corebindings_SRCS shaders.qrc) + shaders.qrc +) -add_library(corebindingsplugin SHARED ${corebindings_SRCS}) target_link_libraries(corebindingsplugin Qt5::Quick Qt5::Qml diff --git a/src/declarativeimports/plasmacomponents/CMakeLists.txt b/src/declarativeimports/plasmacomponents/CMakeLists.txt index 59ee81309..12263569a 100644 --- a/src/declarativeimports/plasmacomponents/CMakeLists.txt +++ b/src/declarativeimports/plasmacomponents/CMakeLists.txt @@ -1,6 +1,8 @@ #find_package(KF5Declarative REQUIRED NO_MODULE) -set(plasmacomponents_SRCS +add_library(plasmacomponentsplugin SHARED) + +target_sources(plasmacomponentsplugin PRIVATE #fullscreensheet.cpp #fullscreenwindow.cpp plasmacomponentsplugin.cpp @@ -10,7 +12,6 @@ set(plasmacomponents_SRCS qmenuitem.cpp ) -add_library(plasmacomponentsplugin SHARED ${plasmacomponents_SRCS}) target_link_libraries(plasmacomponentsplugin Qt5::Core Qt5::Quick diff --git a/src/declarativeimports/plasmaextracomponents/CMakeLists.txt b/src/declarativeimports/plasmaextracomponents/CMakeLists.txt index 3b8b62d1e..10e9c9058 100644 --- a/src/declarativeimports/plasmaextracomponents/CMakeLists.txt +++ b/src/declarativeimports/plasmaextracomponents/CMakeLists.txt @@ -4,14 +4,13 @@ # TYPE REQUIRED # PURPOSE "Provides the ability to access activities from QML." # ) +add_library(plasmaextracomponentsplugin SHARED) -set(plasmaextracomponents_SRCS +target_sources(plasmaextracomponentsplugin PRIVATE appbackgroundprovider.cpp plasmaextracomponentsplugin.cpp fallbackcomponent.cpp - ) - -add_library(plasmaextracomponentsplugin SHARED ${plasmaextracomponents_SRCS}) +) target_link_libraries(plasmaextracomponentsplugin Qt5::Quick diff --git a/src/declarativeimports/platformcomponents/CMakeLists.txt b/src/declarativeimports/platformcomponents/CMakeLists.txt index 34e7f7ba5..84f029b36 100644 --- a/src/declarativeimports/platformcomponents/CMakeLists.txt +++ b/src/declarativeimports/platformcomponents/CMakeLists.txt @@ -1,16 +1,15 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(platformcomponents_SRCS +add_library(platformcomponentsplugin SHARED) + +target_sources(platformcomponentsplugin PRIVATE platformextensionplugin.cpp application.cpp icondialog.cpp - ) +) -add_library(platformcomponentsplugin SHARED ${platformcomponents_SRCS}) - -target_link_libraries( - platformcomponentsplugin +target_link_libraries(platformcomponentsplugin Qt5::Core Qt5::DBus Qt5::Qml diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt index ffcba3a21..15d3ec764 100644 --- a/src/plasma/CMakeLists.txt +++ b/src/plasma/CMakeLists.txt @@ -6,9 +6,16 @@ endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-plasma.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-plasma.h) -########### next target ############### +add_library(KF5Plasma) +add_library(KF5::Plasma ALIAS KF5Plasma) -set(Plasma_LIB_SRCS +set_target_properties(KF5Plasma PROPERTIES + VERSION ${PLASMA_VERSION} + SOVERSION ${PLASMA_SOVERSION} + EXPORT_NAME Plasma +) + +target_sources(KF5Plasma PRIVATE #global plasma.cpp pluginloader.cpp @@ -50,17 +57,17 @@ set(Plasma_LIB_SRCS if(NOT EXCLUDE_DEPRECATED_BEFORE_AND_AT STREQUAL "CURRENT" AND EXCLUDE_DEPRECATED_BEFORE_AND_AT VERSION_LESS 5.83.0) #packages - set(Plasma_LIB_SRCS ${Plasma_LIB_SRCS} package.cpp packagestructure.cpp) + target_sources(KF5Plasma PRIVATE package.cpp packagestructure.cpp) endif() if(HAVE_X11) - set(Plasma_LIB_SRCS ${Plasma_LIB_SRCS} private/effectwatcher.cpp) + target_sources(KF5Plasma PRIVATE private/effectwatcher.cpp) endif() -kconfig_add_kcfg_files(Plasma_LIB_SRCS data/kconfigxt/libplasma-theme-global.kcfgc) +kconfig_add_kcfg_files(KF5Plasma data/kconfigxt/libplasma-theme-global.kcfgc) -ecm_qt_declare_logging_category(Plasma_LIB_SRCS +ecm_qt_declare_logging_category(KF5Plasma HEADER debug_p.h IDENTIFIER LOG_PLASMA CATEGORY_NAME kf.plasma.core @@ -69,8 +76,6 @@ ecm_qt_declare_logging_category(Plasma_LIB_SRCS EXPORT PLASMA ) -add_library(KF5Plasma ${Plasma_LIB_SRCS}) -add_library(KF5::Plasma ALIAS KF5Plasma) ecm_generate_export_header(KF5Plasma EXPORT_FILE_NAME plasma/plasma_export.h BASE_NAME Plasma @@ -120,12 +125,6 @@ target_include_directories(KF5Plasma INTERFACE "$" ) -set_target_properties(KF5Plasma PROPERTIES - VERSION ${PLASMA_VERSION} - SOVERSION ${PLASMA_SOVERSION} - EXPORT_NAME Plasma - ) - ########### install files ############### ecm_generate_headers(Plasma_CamelCase_HEADERS HEADER_NAMES diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index 98acc8f7e..5c9d393eb 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -4,7 +4,16 @@ else() add_definitions(-DHAVE_XCB_SHAPE=0) endif() -set(plasmaquick_LIB_SRC +add_library(KF5PlasmaQuick SHARED) +add_library(KF5::PlasmaQuick ALIAS KF5PlasmaQuick) + +set_target_properties(KF5PlasmaQuick PROPERTIES + VERSION ${PLASMA_VERSION} + SOVERSION ${PLASMA_SOVERSION} + EXPORT_NAME PlasmaQuick +) + +target_sources(KF5PlasmaQuick PRIVATE appletquickitem.cpp debug_p.cpp dialog.cpp @@ -21,10 +30,10 @@ set(plasmaquick_LIB_SRC ) if(HAVE_KWAYLAND) - set(plasmaquick_LIB_SRC ${plasmaquick_LIB_SRC} waylandintegration.cpp) + target_sources(KF5PlasmaQuick PRIVATE waylandintegration.cpp) endif() -ecm_qt_declare_logging_category(PlasmaQuick_LIB_SRCS +ecm_qt_declare_logging_category(KF5PlasmaQuick HEADER debug_p.h IDENTIFIER LOG_PLASMAQUICK CATEGORY_NAME kf.plasma.quick @@ -33,8 +42,6 @@ ecm_qt_declare_logging_category(PlasmaQuick_LIB_SRCS EXPORT PLASMA ) -add_library(KF5PlasmaQuick SHARED ${plasmaquick_LIB_SRC}) -add_library(KF5::PlasmaQuick ALIAS KF5PlasmaQuick) target_include_directories(KF5PlasmaQuick PUBLIC "$") target_link_libraries(KF5PlasmaQuick @@ -75,12 +82,6 @@ if(HAVE_X11) endif() endif() -set_target_properties(KF5PlasmaQuick PROPERTIES - VERSION ${PLASMA_VERSION} - SOVERSION ${PLASMA_SOVERSION} - EXPORT_NAME PlasmaQuick - ) - install(TARGETS KF5PlasmaQuick EXPORT KF5PlasmaQuickTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) ecm_generate_export_header(KF5PlasmaQuick diff --git a/src/scriptengines/qml/CMakeLists.txt b/src/scriptengines/qml/CMakeLists.txt index 701aeb36e..efb70345f 100644 --- a/src/scriptengines/qml/CMakeLists.txt +++ b/src/scriptengines/qml/CMakeLists.txt @@ -6,15 +6,16 @@ if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) endif() #DECLARATIVE APPLET -set(declarative_appletscript_SRCS +add_library(plasma_appletscript_declarative MODULE) + +target_sources(plasma_appletscript_declarative PRIVATE plasmoid/declarativeappletscript.cpp plasmoid/dropmenu.cpp plasmoid/appletinterface.cpp plasmoid/containmentinterface.cpp plasmoid/wallpaperinterface.cpp - ) +) -add_library(plasma_appletscript_declarative MODULE ${declarative_appletscript_SRCS} ) set_target_properties(plasma_appletscript_declarative PROPERTIES PREFIX "") kcoreaddons_desktop_to_json( diff --git a/templates/cpp-plasmoid/src/CMakeLists.txt b/templates/cpp-plasmoid/src/CMakeLists.txt index 548e77732..cbc9011d3 100644 --- a/templates/cpp-plasmoid/src/CMakeLists.txt +++ b/templates/cpp-plasmoid/src/CMakeLists.txt @@ -1,11 +1,7 @@ # TODO: adapt "org.kde.plasma" here & elsewhere if needed (see README) add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.%{APPNAMELC}\") -set(%{APPNAMELC}_SRCS - %{APPNAMELC}.cpp -) - -add_library(plasma_applet_%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) +add_library(plasma_applet_%{APPNAMELC} MODULE %{APPNAMELC}.cpp) kcoreaddons_desktop_to_json(plasma_applet_%{APPNAMELC} package/metadata.desktop SERVICE_TYPES plasma-applet.desktop) diff --git a/templates/plasma-wallpaper-with-qml-extension/plugin/CMakeLists.txt b/templates/plasma-wallpaper-with-qml-extension/plugin/CMakeLists.txt index a6426265f..8567c9ce4 100644 --- a/templates/plasma-wallpaper-with-qml-extension/plugin/CMakeLists.txt +++ b/templates/plasma-wallpaper-with-qml-extension/plugin/CMakeLists.txt @@ -1,10 +1,6 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_wallpaper_org.kde.plasma.%{APPNAMELC}\") -set(%{APPNAMELC}plugin_SRCS - %{APPNAMELC}plugin.cpp -) - -add_library(%{APPNAMELC}plugin SHARED ${%{APPNAMELC}plugin_SRCS}) +add_library(%{APPNAMELC}plugin SHARED %{APPNAMELC}plugin.cpp) target_link_libraries(%{APPNAMELC}plugin KF5::I18n diff --git a/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt b/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt index 46cdf13ab..526fe57cf 100644 --- a/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt +++ b/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt @@ -1,10 +1,6 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.%{APPNAMELC}\") -set(%{APPNAMELC}plugin_SRCS - %{APPNAMELC}plugin.cpp -) - -add_library(%{APPNAMELC}plugin SHARED ${%{APPNAMELC}plugin_SRCS}) +add_library(%{APPNAMELC}plugin SHARED %{APPNAMELC}plugin.cpp) target_link_libraries(%{APPNAMELC}plugin KF5::I18n