Commit 420cb00b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Clean up the CMake build system a bit

Most porting to use ecm_add_test and target_include_directories,
couple fixes of include paths and linking libraries. We try to make
sure that libs and apps don't have any other include paths other than
their own and those provided by their dependencies.

This will be useful in future if we try to split the kdepim repo.
parent 0f44746d
project(archivemailagent)
include_directories(
${CMAKE_SOURCE_DIR}/libkdepim
${CMAKE_SOURCE_DIR}/mailcommon
${CMAKE_SOURCE_DIR}/messagecomposer/
)
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_archivemail_agent\")
set(archivemailagent_SRCS
......
project(followupreminderagent)
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_followupreminder_agent\")
set(followupreminderlib_SRCS
......@@ -17,12 +15,13 @@ kconfig_add_kcfg_files(followupreminderlib_SRCS
add_library( followupreminder ${followupreminderlib_SRCS} )
generate_export_header(followupreminder BASE_NAME followupreminder)
target_link_libraries( followupreminder KF5::CoreAddons KF5::ConfigGui Qt5::DBus )
target_include_directories(followupreminder PUBLIC $<TARGET_PROPERTY:KF5::AkonadiCore,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(followupreminder PUBLIC "$<BUILD_INTERFACE:${followupreminderagent_SOURCE_DIR};${followupreminderagent_BINARY_DIR}>")
set_target_properties( followupreminder PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION} )
install( TARGETS followupreminder ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} )
################ Next target ########################
set(followupreminderagent_job_SRCS
jobs/followupreminderjob.cpp
......
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
remove_definitions( -DQT_NO_CAST_FROM_BYTEARRAY )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. )
# Convenience macro to add unit tests.
macro( followupreminder_agent _source )
set( _test ${_source} ../followupreminderinfodialog.cpp ../followupreminderinfowidget.cpp ../jobs/followupremindershowmessagejob.cpp ../followupremindernoanswerdialog.cpp ../followupreminderagent_debug.cpp)
get_filename_component( _name ${_source} NAME_WE )
add_executable( ${_name} ${_test} )
add_test( ${_name} ${_name} )
ecm_mark_as_test(followupreminder-${_name})
target_link_libraries( ${_name} Qt5::Test KF5::AkonadiCore followupreminder Qt5::Widgets KF5::I18n KF5::XmlGui KF5::Service)
set( _test ${_source} ../followupreminderinfodialog.cpp ../followupreminderinfowidget.cpp ../jobs/followupremindershowmessagejob.cpp ../followupremindernoanswerdialog.cpp ../followupreminderagent_debug.cpp)
get_filename_component( _name ${_source} NAME_WE )
ecm_add_test(${_test}
TEST_NAME ${_name}
NAME_PREFIX "followupreminder-"
LINK_LIBRARIES Qt5::Test KF5::AkonadiCore followupreminder Qt5::Widgets KF5::I18n KF5::XmlGui KF5::Service
)
endmacro()
followupreminder_agent(followupreminderinfotest.cpp)
......
......@@ -4,12 +4,6 @@ add_subdirectory( kconf_update )
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_mailfilter_agent\")
include_directories(
${Boost_INCLUDE_DIR}
)
set(akonadi_mailfilter_agent_SRCS
dummykernel.cpp
filterlogdialog.cpp
......
......@@ -21,15 +21,25 @@ kconfig_add_kcfg_files(sendlaterlib_SRCS
ki18n_wrap_ui(sendlaterlib_SRCS ui/sendlaterwidget.ui)
add_library( sendlater ${sendlaterlib_SRCS} )
generate_export_header(sendlater BASE_NAME sendlater)
target_link_libraries( sendlater PUBLIC KF5::AkonadiCore KF5::ConfigCore Qt5::Widgets PRIVATE KF5::I18n KF5::WidgetsAddons KF5::ConfigGui Qt5::DBus )
target_link_libraries(sendlater
PUBLIC
KF5::AkonadiCore
KF5::ConfigCore
Qt5::Widgets
PRIVATE
KF5::I18n
KF5::WidgetsAddons
KF5::ConfigGui
Qt5::DBus
)
target_include_directories(sendlater PUBLIC "$<BUILD_INTERFACE:${sendlateragent_SOURCE_DIR};${sendlateragent_BINARY_DIR}>")
set_target_properties( sendlater PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION} )
install( TARGETS sendlater ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} )
############# Next target ###################
set(sendlateragent_SRCS
sendlateragent_debug.cpp
......
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. )
remove_definitions( -DQT_NO_CAST_FROM_BYTEARRAY )
# Convenience macro to add unit tests.
macro( sendlater_agent _source )
set( _test ${_source} ../sendlaterconfiguredialog.cpp ../sendlaterconfigurewidget.cpp)
ki18n_wrap_ui(_test ../ui/sendlaterconfigurewidget.ui)
get_filename_component( _name ${_source} NAME_WE )
add_executable( ${_name} ${_test} )
add_test( ${_name} ${_name} )
ecm_mark_as_test(sendlatertest-${_name})
target_link_libraries( ${_name} Qt5::Test KF5::AkonadiCore sendlater pimcommon)
macro(add_sendlater_agent_test _source )
set(_test ${_source} ../sendlaterconfiguredialog.cpp ../sendlaterconfigurewidget.cpp)
ki18n_wrap_ui(_test ../ui/sendlaterconfigurewidget.ui)
get_filename_component(_name ${_source} NAME_WE)
ecm_add_test(${_test}
TEST_NAME ${_name}
NAME_PREFIX "sendlateragent-"
LINK_LIBRARIES Qt5::Test KF5::AkonadiCore sendlater pimcommon
)
endmacro()
sendlater_agent(sendlaterinfotest.cpp)
sendlater_agent(sendlaterconfiguredialogtest.cpp)
sendlater_agent(sendlaterconfigtest.cpp)
sendlater_agent(sendlaterdialogtest.cpp)
add_sendlater_agent_test(sendlaterinfotest.cpp)
add_sendlater_agent_test(sendlaterconfiguredialogtest.cpp)
add_sendlater_agent_test(sendlaterconfigtest.cpp)
add_sendlater_agent_test(sendlaterdialogtest.cpp)
include_directories(
${CMAKE_SOURCE_DIR}/akregator/interfaces
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
......
......@@ -17,6 +17,8 @@ target_link_libraries(akregatorinterfaces
KF5::Syndication
)
target_include_directories(akregatorinterfaces PUBLIC "$<BUILD_INTERFACE:${akregator_SOURCE_DIR}/interfaces;${akregator_BINARY_DIR}/interfaces>")
set_target_properties(akregatorinterfaces PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION}
)
......
......@@ -3,10 +3,6 @@
add_subdirectory(about)
add_subdirectory(icons)
include_directories(
${CMAKE_SOURCE_DIR}/akregator/interfaces
${CMAKE_BINARY_DIR}/akregator/interfaces
)
########### next target ###############
......@@ -70,6 +66,8 @@ PRIVATE
pimcommon
)
target_include_directories(akregatorprivate PUBLIC "$<BUILD_INTERFACE:${akregator_SOURCE_DIR}/src;${akregator_BINARY_DIR}/src>")
set_target_properties(akregatorprivate
PROPERTIES VERSION ${KDEPIM_LIB_VERSION}
SOVERSION ${KDEPIM_LIB_SOVERSION}
......
if (KF5GAPI_FOUND)
include_directories(${LibKGAPI2_INCLUDE_DIR} )
add_definitions(-DHAVE_GAPIBLOGGER_SUPPORT)
endif()
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/libkdepim
${CMAKE_SOURCE_DIR}/pimcommon
)
set(blogilo_SRCS
blogilomigrateapplication.cpp
blogilo_debug.cpp
......
project(calendarsupport)
# Commented because it uses your real calendar. You can loose data.
# I'll uncomment this when tests use testrunner.
# add_subdirectory(next/tests)
include_directories(
${Boost_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/calendarviews
)
add_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_CAST_TO_ASCII)
add_definitions(-DTRANSLATION_DOMAIN=\"calendarsupport\")
########### next target ###############
......@@ -75,6 +72,8 @@ PRIVATE
kdepimdbusinterfaces
)
target_include_directories(calendarsupport PUBLIC "$<BUILD_INTERFACE:${calendarsupport_SOURCE_DIR};${calendarsupport_BINARY_DIR};${Boost_INCLUDE_DIRS}>")
set_target_properties(calendarsupport
PROPERTIES VERSION ${KDEPIM_LIB_VERSION}
SOVERSION ${KDEPIM_LIB_SOVERSION}
......@@ -82,28 +81,33 @@ set_target_properties(calendarsupport
install(TARGETS calendarsupport ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
############# Next target #######################
set(calendarsupportcollectionpage_LIB_SRCS
collectiongeneralpage.cpp
)
add_library(calendarsupportcollectionpage ${calendarsupportcollectionpage_LIB_SRCS})
add_dependencies(calendarsupportcollectionpage mailcommon)
generate_export_header(calendarsupportcollectionpage BASE_NAME calendarsupportcollectionpage)
target_link_libraries(
calendarsupportcollectionpage
PRIVATE
PUBLIC
KF5::AkonadiCore
KF5::CalendarCore
mailcommon
PRIVATE
KF5::CalendarCore
pimcommon
KF5::AkonadiCalendar
)
target_include_directories(calendarsupportcollectionpage PUBLIC "$<BUILD_INTERFACE:${calendarsupport_SOURCE_DIR};${calendarsupport_BINARY_DIR};${Boost_INCLUDE_DIRS}>")
set_target_properties(calendarsupportcollectionpage
PROPERTIES VERSION ${KDEPIM_LIB_VERSION}
SOVERSION ${KDEPIM_LIB_VERSION}
)
install(TARGETS calendarsupportcollectionpage ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES calendarplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
......@@ -26,7 +26,7 @@
#include "journalprint.h"
#include "yearprint.h"
#include <calendarviews/prefs.h>
//#include <calendarviews/prefs.h>
#include <KDEPrintDialog>
#include <KMessageBox>
......
......@@ -22,9 +22,6 @@ if(EVENTVIEWS_NODECOS)
add_definitions(-DEVENTVIEWS_NODECOS)
endif()
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
########### next target ###############
......@@ -92,7 +89,7 @@ PUBLIC
KF5::AkonadiCore
kdepim
calendarsupport
KF5::CalendarCore
KF5::CalendarUtils
KF5::AkonadiCalendar
......@@ -101,6 +98,8 @@ PRIVATE
kdgantt2
)
target_include_directories(eventviews PUBLIC "$<BUILD_INTERFACE:${calendarView_SOURCE_DIR};${calendarView_BINARY_DIR}>")
set_target_properties(eventviews PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION})
install(TARGETS eventviews ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES agenda/calendardecoration.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
......
include_directories(${CMAKE_SOURCE_DIR}/calendarviews
)
set(createcolorgui_test createcolorgui_test.cpp)
add_executable(createcolorgui_test ${createcolorgui_test})
ecm_mark_as_test(createcolorgui_test)
......
project(calendarviewsapp)
include_directories(
${calendarView_SOURCE_DIR}/
${calendarView_SOURCE_DIR}/agenda
)
set(viewerapp_SRCS
main.cpp
mainwindow.cpp
......
......@@ -9,19 +9,12 @@ set(calendarjanitor_SRCS
main.cpp
options.cpp)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${Boost_INCLUDE_DIRS}
)
#file(GLOB ICONS_SRCS "${KDE4_ICON_DIR}/oxygen/*/apps/office-calendar.png")
#ecm_add_app_icon(calendarjanitor_SRCS ICONS ${ICONS_SRCS})
add_executable(calendarjanitor ${calendarjanitor_SRCS})
target_link_libraries(calendarjanitor
KF5::CalendarUtils
KF5::CalendarCore
kdepim
......
......@@ -15,19 +15,12 @@ set(konsolekalendar_SRCS
konsolekalendar.cpp
main.cpp )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${Boost_INCLUDE_DIRS}
)
#file(GLOB ICONS_SRCS "${KDE4_ICON_DIR}/oxygen/*/apps/office-calendar.png")
#ecm_add_app_icon(konsolekalendar_SRCS ICONS ${ICONS_SRCS})
add_executable(konsolekalendar ${konsolekalendar_SRCS})
target_link_libraries(konsolekalendar
KF5::CalendarUtils
KF5::CalendarCore
kdepim
......
project(grantleeditor)
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
......
project( contactprintthemeeditor )
include_directories(
${CMAKE_SOURCE_DIR}/pimcommon/
${CMAKE_SOURCE_DIR}/grantleeeditor/grantleethemeeditor
${CMAKE_SOURCE_DIR}/kaddressbookgrantlee
${CMAKE_SOURCE_DIR}/grantleeeditor/
)
set(contactprintthemeeditor_SRCS
main.cpp
contactprintthemeeditor_debug.cpp
......@@ -28,12 +18,12 @@ set(contactprintthemeeditor_SRCS
add_executable(contactprintthemeeditor ${contactprintthemeeditor_SRCS} )
target_link_libraries(contactprintthemeeditor
KF5::DBusAddons
KF5::NewStuff
target_link_libraries(contactprintthemeeditor
KF5::DBusAddons
KF5::NewStuff
KF5::AkonadiContact
pimcommon
grantleethemeeditor
pimcommon
grantleethemeeditor
kaddressbookgrantlee
)
......
project( contactthemeeditor )
include_directories(
${CMAKE_SOURCE_DIR}/pimcommon/
${CMAKE_SOURCE_DIR}/grantleeeditor/grantleethemeeditor
${CMAKE_SOURCE_DIR}/kaddressbookgrantlee
${CMAKE_SOURCE_DIR}/grantleeeditor/
)
set(contactthemeeditor_SRCS
main.cpp
contactthemeeditor_debug.cpp
......@@ -27,12 +18,12 @@ set(contactthemeeditor_SRCS
add_executable(contactthemeeditor ${contactthemeeditor_SRCS} )
target_link_libraries(contactthemeeditor
KF5::DBusAddons
KF5::NewStuff
target_link_libraries(contactthemeeditor
KF5::DBusAddons
KF5::NewStuff
KF5::AkonadiContact
pimcommon
grantleethemeeditor
pimcommon
grantleethemeeditor
kaddressbookgrantlee
)
......
......@@ -2,10 +2,6 @@ project(grantleethemeeditor)
add_definitions(-DTRANSLATION_DOMAIN=\"libgrantleethemeeditor\")
include_directories(
${CMAKE_SOURCE_DIR}/pimcommon/
)
set(libgrantleethemeeditor_SRCS
newthemedialog.cpp
......@@ -33,8 +29,9 @@ ki18n_wrap_ui(libgrantleethemeeditor_SRCS
add_library(grantleethemeeditor ${libgrantleethemeeditor_SRCS})
generate_export_header(grantleethemeeditor BASE_NAME grantleethemeeditor)
target_link_libraries(grantleethemeeditor KF5::Archive KF5::PimTextEdit pimcommon
)
target_include_directories(grantleethemeeditor PUBLIC "$<BUILD_INTERFACE:${grantleeditor_SOURCE_DIR};${grantleethemeeditor_SOURCE_DIR};${grantleethemeeditor_BINAY_DIR}>")
target_link_libraries(grantleethemeeditor KF5::Archive KF5::PimTextEdit pimcommon)
set_target_properties(grantleethemeeditor PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION})
install(TARGETS grantleethemeeditor ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
project( headerthemeeditor )
include_directories(
${CMAKE_SOURCE_DIR}/messageviewer
${CMAKE_SOURCE_DIR}/pimcommon/
${CMAKE_SOURCE_DIR}/grantleeeditor/grantleethemeeditor
${CMAKE_SOURCE_DIR}/grantleeeditor/
)
set(headerthemeeditor_SRCS
main.cpp
headerthemeeditor_debug.cpp
......
......@@ -3,9 +3,11 @@ project(grantleetheme)
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
add_definitions(-DTRANSLATION_DOMAIN=\"libgrantleetheme\")
set(libgrantleetheme_SRCS grantleetheme.cpp grantleethememanager.cpp
)
set(libgrantleetheme_SRCS
grantleetheme.cpp
grantleethememanager.cpp
)
kconfig_add_kcfg_files(libgrantleetheme_SRCS
globalsettings_base.kcfgc
......@@ -14,11 +16,13 @@ kconfig_add_kcfg_files(libgrantleetheme_SRCS
add_library(grantleetheme ${libgrantleetheme_SRCS})
generate_export_header(grantleetheme BASE_NAME grantleetheme)
target_link_libraries(grantleetheme KF5::NewStuff KF5::I18n )
target_link_libraries(grantleetheme KF5::NewStuff KF5::I18n)
set_target_properties(grantleetheme PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION})
install(TARGETS grantleetheme ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
target_include_directories(grantleetheme PUBLIC "$<BUILD_INTERFACE:${grantleetheme_SOURCE_DIR};${grantleetheme_BINARY_DIR}>")
add_subdirectory(kconf_update)
if (BUILD_TESTING)
add_subdirectory(autotest)
......
add_definitions( -DGRANTLEETHEME_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( grantlee_theme_source grantleethemetest.cpp ../grantleetheme.cpp)
add_executable( grantleethemetest ${grantlee_theme_source})
add_test(grantleethemetest grantleethemetest)
ecm_mark_as_test(grantleethemetest)
target_link_libraries( grantleethemetest Qt5::Test grantleetheme)
ecm_add_test(grantleethemetest.cpp
NAME_PREFIX "grantleetheme-"
LINK_LIBRARIES Qt5::Test grantleetheme
)
......@@ -16,7 +16,7 @@
*/
#include "grantleethemetest.h"
#include "../grantleetheme.h"
#include "grantleetheme.h"
#include <qtest.h>
#include <QDir>
......
......@@ -2,8 +2,7 @@ project(importwizard)
include_directories(
${CMAKE_SOURCE_DIR}/mailcommon/filter/
${CMAKE_SOURCE_DIR}/importwizard/autodetect/
${importwizard_SOURCE_DIR}/autodetect/
)
......
project(incidenceeditorng)
if(KDEPIM_MOBILE_UI)
remove_definitions(-DKDEPIM_MOBILE_UI)
endif()
add_definitions(-DTRANSLATION_DOMAIN=\"libincidenceeditors\")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
set(incidenceeditors_ng_shared_LIB_SRCS
incidenceeditor_debug.cpp
attachmenteditdialog.cpp
......@@ -101,6 +99,7 @@ add_library(incidenceeditorsng ${incidenceeditors_ng_desktop_LIB_SRCS})
generate_export_header(incidenceeditorsng BASE_NAME incidenceeditors_ng)
target_link_libraries(incidenceeditorsng
PUBLIC
KF5::AkonadiCalendar
KF5::AkonadiMime
KF5::CalendarCore
......@@ -108,10 +107,11 @@ target_link_libraries(incidenceeditorsng
KF5::MailTransport
KF5::Codecs
kdepim
kdepimdbusinterfaces # For UriHandler
calendarsupport # For KCalPrefs
eventviews
kdgantt2 # For FreeBusy Editor
PRIVATE
kdepimdbusinterfaces # For UriHandler
)
set_target_properties(incidenceeditorsng
......@@ -121,6 +121,7 @@ set_target_properties(incidenceeditorsng
install(TARGETS incidenceeditorsng ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
target_include_directories(incidenceeditorsng PUBLIC "$<BUILD_INTERFACE:${incidenceeditorng_SOURCE_DIR};${incidenceeditorng_BINARY_DIR}>")
set(testincidenceeditor_SRCS main.cpp)
......
......@@ -4,7 +4,6 @@ project(kaddressbook)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/xxport/shared
${CMAKE_CURRENT_SOURCE_DIR}/printing/
${Grantlee_INCLUDE_DIRS}
)
......@@ -157,6 +156,8 @@ if(KF5Prison_FOUND)
target_link_libraries(kaddressbookprivate KF5::Prison)
endif()
target_include_directories(kaddressbookprivate PUBLIC "$<BUILD_INTERFACE:${kaddressbook_SOURCE_DIR};${kaddressbook_BINARY_DIR}>")
set_target_properties(kaddressbookprivate PROPERTIES VERSION ${KDEPIM_LIB_VERSION} SOVERSION ${KDEPIM_LIB_SOVERSION})
install(TARGETS kaddressbookprivate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
......
include_directories(${CMAKE_SOURCE_DIR}/kaddressbook)
include_directories(${kaddressbook_SOURCE_DIR})