Commit 0397c2b8 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Install headers with C++ namespace prefix, to avoid lookup conflicts

So far headers for the libraries AknoadiCore, AkonadiWidgtets, AkonadiXml,
and AkonadiAgents were installed directly into the directory given as
include base dir, as e.g. noted in the link interface.
Due to generic names of the headers, without the project prefix, e.g.
#include <item.h>
#include <job.h>
could run chance to instead match other headers from the include
directories of other projects.

Given the practice to uee the C++ namespace as path prefix in the
include dirs, this patch changes the installation to install the normal
headers into an akonadi/ and the CamelCase headers into a Akonadi/ subdir
of the respective base include dir, so projects linking to Akonadi
libraries can then use
#include <akonadi/item.h>
or
#include <Akonadi/Item>
with less chance to have the wrong headers picked.

To make the headers from AkonadiAgents, AkonadiWidgets and AkonadiXml
properly work also when being used from their installed location,
they n...
parent bc0c31ce
Pipeline #79187 canceled with stage
......@@ -85,3 +85,103 @@ function(akonadi_add_xmllint_test)
file(RELATIVE_PATH xml_relpath ${CMAKE_CURRENT_BINARY_DIR} ${TEST_XML})
add_test(${TEST_UNPARSED_ARGUMENTS} ${XMLLINT_EXECUTABLE} --noout --schema ${xsd_relpath} ${xml_relpath})
endfunction()
function(_akonadi_generate_compat_header compat_header header include_path)
set(content "#include <akonadi/${header}>\n")
# enable once all PIM repos have been adapted, too much noise before
# string(APPEND content "#pragma message(\"Deprecated header, will be removed for Akonadi 5.19. Use #include <${include_path}> instead.\")\n")
file(GENERATE OUTPUT "${compat_header}" CONTENT "${content}")
endfunction()
function(akonadi_generate_headers_with_deprecated camelcase_forwarding_headers_var)
# extend as needed to support those ecm_generate_headers arguments akonadi cmake code does use
set(options)
set(oneValueArgs PREFIX REQUIRED_HEADERS DEPRECATED_DESTINATION RELATIVE)
set(multiValueArgs HEADER_NAMES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unexpected argument to akonadi_generate_headers: ${ARG_UNPARSED_ARGUMENTS}")
endif()
if (NOT ARG_DEPRECATED_DESTINATION)
message(FATAL_ERROR "DEPRECATED_DESTINATION argument is required with akonadi_generate_headers")
endif()
# forward for normal macro
set(ecmOneValueArgL)
foreach(ecmOneValueArg PREFIX REQUIRED_HEADERS RELATIVE)
if (ARG_${ecmOneValueArg} )
list(APPEND ecmOneValueArgL ${ecmOneValueArg} ${ARG_${ecmOneValueArg}})
endif()
endforeach()
ecm_generate_headers(${camelcase_forwarding_headers_var}
${ecmOneValueArgL}
HEADER_NAMES ${ARG_HEADER_NAMES}
)
set(${camelcase_forwarding_headers_var} ${${camelcase_forwarding_headers_var}} PARENT_SCOPE)
if (ARG_REQUIRED_HEADERS)
set(${ARG_REQUIRED_HEADERS} ${${ARG_REQUIRED_HEADERS}} PARENT_SCOPE)
endif ()
# compat headers to be removed before release of 5.19
if(PIM_VERSION VERSION_GREATER_EQUAL "5.18.80")
message(AUTHOR_WARNING "Remove usage of akonadi_generate_headers_with_deprecated()")
return()
endif()
# generated deprecated headers and install
set(compat_headers)
foreach(classname ${ARG_HEADER_NAMES})
string(TOLOWER ${classname} classname_lc)
set(HEADER_NAME "${classname_lc}.h")
# normal header
set(compat_header "${CMAKE_CURRENT_BINARY_DIR}/compat/${HEADER_NAME}")
_akonadi_generate_compat_header("${compat_header}" "${HEADER_NAME}" "akonadi/${HEADER_NAME}")
list(APPEND compat_headers ${compat_header})
# CamelCase header
set(compat_header "${CMAKE_CURRENT_BINARY_DIR}/compat/${classname}")
_akonadi_generate_compat_header("${compat_header}" "${HEADER_NAME}" "Akonadi/${classname}")
list(APPEND compat_headers ${compat_header})
endforeach()
install(FILES ${compat_headers}
DESTINATION ${ARG_DEPRECATED_DESTINATION}
COMPONENT Devel
)
endfunction()
function(akonadi_generate_deprecated_headers)
# extend as needed to support those ecm_generate_headers arguments akonadi cmake code does use
set(options)
set(oneValueArgs DEPRECATED_DESTINATION)
set(multiValueArgs HEADERS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unexpected argument to akonadi_generate_deprecated_headers: ${ARG_UNPARSED_ARGUMENTS}")
endif()
if (NOT ARG_DEPRECATED_DESTINATION)
message(FATAL_ERROR "DEPRECATED_DESTINATION argument is required with akonadi_generate_deprecated_headers")
endif()
# compat headers to be removed before release of 5.19
if(PIM_VERSION VERSION_GREATER_EQUAL "5.18.80")
message(AUTHOR_WARNING "Remove usage of akonadi_generate_deprecated_headers()")
return()
endif()
# generated deprecated headers and install
set(compat_headers)
foreach(HEADER_NAME ${ARG_HEADERS})
# normal header
set(compat_header "${CMAKE_CURRENT_BINARY_DIR}/compat/${HEADER_NAME}")
_akonadi_generate_compat_header("${compat_header}" "${HEADER_NAME}" "akonadi/${HEADER_NAME}")
list(APPEND compat_headers ${compat_header})
endforeach()
install(FILES ${compat_headers}
DESTINATION ${ARG_DEPRECATED_DESTINATION}
COMPONENT Devel
)
endfunction()
# base install include dir
set(AkonadiAgentBase_INSTALL_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiAgentBase")
add_library(KF5AkonadiAgentBase)
add_library(KF5::AkonadiAgentBase ALIAS KF5AkonadiAgentBase)
......@@ -7,7 +10,7 @@ ecm_qt_declare_logging_category(KF5AkonadiAgentBase HEADER akonadiagentbase_debu
EXPORT AKONADI
)
ecm_generate_headers(AkonadiAgentBase_HEADERS
akonadi_generate_headers_with_deprecated(AkonadiAgentBase_CC_HEADERS
HEADER_NAMES
AccountsIntegration
AgentBase
......@@ -17,10 +20,15 @@ ecm_generate_headers(AkonadiAgentBase_HEADERS
ResourceSettings
TransportResourceBase
REQUIRED_HEADERS AkonadiAgentBase_HEADERS
DEPRECATED_DESTINATION ${AkonadiAgentBase_INSTALL_INCLUDEDIR}
)
KCONFIG_ADD_KCFG_FILES(KF5AkonadiAgentBase resourcebasesettings.kcfgc)
akonadi_generate_deprecated_headers(
HEADERS resourcebasesettings.h
DEPRECATED_DESTINATION ${AkonadiAgentBase_INSTALL_INCLUDEDIR}
)
qt_add_dbus_interfaces(akonadiagentbase_SRCS ${Akonadi_SOURCE_DIR}/src/interfaces/org.freedesktop.Akonadi.Tracer.xml )
......@@ -62,7 +70,7 @@ endif()
generate_export_header(KF5AkonadiAgentBase BASE_NAME akonadiagentbase)
target_include_directories(KF5AkonadiAgentBase INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiAgentBase>")
target_include_directories(KF5AkonadiAgentBase INTERFACE "$<INSTALL_INTERFACE:${AkonadiAgentBase_INSTALL_INCLUDEDIR}>")
target_link_libraries(KF5AkonadiAgentBase
PUBLIC
......@@ -105,7 +113,14 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/akonadiagentbase_export.h
${CMAKE_CURRENT_BINARY_DIR}/resourcebasesettings.h
${AkonadiAgentBase_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiAgentBase COMPONENT Devel
DESTINATION ${AkonadiAgentBase_INSTALL_INCLUDEDIR}/akonadi
COMPONENT Devel
)
install(FILES
${AkonadiAgentBase_CC_HEADERS}
DESTINATION ${AkonadiAgentBase_INSTALL_INCLUDEDIR}/Akonadi
COMPONENT Devel
)
install(FILES
......
......@@ -11,7 +11,8 @@
#pragma once
#include "akonadiagentbase_export.h"
#include "item.h"
// AkonadiCore
#include <akonadi/item.h>
#include <QApplication>
......
......@@ -10,8 +10,9 @@
#include "agentbase.h"
#include "akonadiagentbase_export.h"
#include "collection.h"
#include "item.h"
// AkonadiCore
#include <akonadi/collection.h>
#include <akonadi/item.h>
namespace Akonadi
{
......
......@@ -11,9 +11,10 @@
#include "agentbase.h"
#include "akonadiagentbase_export.h"
#include "collection.h"
#include "item.h"
#include "itemsync.h"
// AkonadiCore
#include <akonadi/collection.h>
#include <akonadi/item.h>
#include <akonadi/itemsync.h>
class KJob;
class Akonadi__ResourceAdaptor;
......
......@@ -6,4 +6,4 @@ ItemAccessors=true
Mutators=true
Visibility=AKONADIAGENTBASE_EXPORT
SetUserTextx=true
IncludeFiles=akonadiagentbase_export.h
IncludeFiles=\"akonadiagentbase_export.h\"
......@@ -7,7 +7,8 @@
#pragma once
#include "akonadiagentbase_export.h"
#include "item.h"
// AkonadiCore
#include <akonadi/item.h>
#include <QString>
......
......@@ -9,6 +9,9 @@ if (BUILD_QCH)
endif()
configure_file(akonaditests_export.h.in "${CMAKE_CURRENT_BINARY_DIR}/akonaditests_export.h")
# base install include dir
set(AkonadiCore_INSTALL_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiCore")
set(akonadicore_base_SRCS
agentconfigurationbase.cpp
agentconfigurationfactorybase.cpp
......@@ -71,7 +74,7 @@ set(akonadicore_base_SRCS
typepluginloader.cpp
)
ecm_generate_headers(AkonadiCore_base_HEADERS
akonadi_generate_headers_with_deprecated(AkonadiCore_base_CC_HEADERS
HEADER_NAMES
AbstractDifferencesReporter
AgentConfigurationBase
......@@ -111,6 +114,12 @@ ecm_generate_headers(AkonadiCore_base_HEADERS
TrashSettings
CollectionPathResolver
REQUIRED_HEADERS AkonadiCore_base_HEADERS
PREFIX Akonadi
DEPRECATED_DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}
)
akonadi_generate_deprecated_headers(
HEADERS qtest_akonadi.h
DEPRECATED_DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}
)
set(akonadicore_attributes_SRCS
......@@ -131,7 +140,7 @@ set(akonadicore_attributes_SRCS
attributes/tagattribute.cpp
)
ecm_generate_headers(AkonadiCore_attributes_HEADERS
akonadi_generate_headers_with_deprecated(AkonadiCore_attributes_CC_HEADERS
HEADER_NAMES
Attribute
CollectionColorAttribute
......@@ -148,6 +157,8 @@ ecm_generate_headers(AkonadiCore_attributes_HEADERS
TagAttribute
REQUIRED_HEADERS AkonadiCore_attributes_HEADERS
RELATIVE attributes
PREFIX Akonadi
DEPRECATED_DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}
)
set(akonadicore_models_SRCS
......@@ -170,7 +181,7 @@ set(akonadicore_models_SRCS
models/trashfilterproxymodel.cpp
)
ecm_generate_headers(AkonadiCore_models_HEADERS
akonadi_generate_headers_with_deprecated(AkonadiCore_models_CC_HEADERS
HEADER_NAMES
AgentFilterProxyModel
AgentInstanceModel
......@@ -188,6 +199,8 @@ ecm_generate_headers(AkonadiCore_models_HEADERS
TrashFilterProxyModel
REQUIRED_HEADERS AkonadiCore_models_HEADERS
RELATIVE models
PREFIX Akonadi
DEPRECATED_DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}
)
set(akonadicore_jobs_SRCS
......@@ -234,7 +247,7 @@ set(akonadicore_jobs_SRCS
jobs/unlinkjob.cpp
)
ecm_generate_headers(AkonadiCore_jobs_HEADERS
akonadi_generate_headers_with_deprecated(AkonadiCore_jobs_CC_HEADERS
HEADER_NAMES
AgentInstanceCreateJob
CollectionAttributesSynchronizationJob
......@@ -273,6 +286,8 @@ ecm_generate_headers(AkonadiCore_jobs_HEADERS
UnlinkJob
REQUIRED_HEADERS AkonadiCore_jobs_HEADERS
RELATIVE jobs
PREFIX Akonadi
DEPRECATED_DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}
)
set(akonadicore_dbus_xml ${Akonadi_SOURCE_DIR}/src/interfaces/org.freedesktop.Akonadi.NotificationManager.xml)
......@@ -311,7 +326,7 @@ add_library(KF5AkonadiCore ${akonadicore_SRCS})
generate_export_header(KF5AkonadiCore BASE_NAME akonadicore)
add_library(KF5::AkonadiCore ALIAS KF5AkonadiCore)
target_include_directories(KF5AkonadiCore INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiCore>")
target_include_directories(KF5AkonadiCore INTERFACE "$<INSTALL_INTERFACE:${AkonadiCore_INSTALL_INCLUDEDIR}>")
target_include_directories(KF5AkonadiCore PUBLIC "$<BUILD_INTERFACE:${Akonadi_SOURCE_DIR}/src/core;${Akonadi_BINARY_DIR}/src/core;${Akonadi_BINARY_DIR}/src/private>")
target_include_directories(KF5AkonadiCore PUBLIC "$<BUILD_INTERFACE:${Akonadi_BINARY_DIR};${Akonadi_SOURCE_DIR}/src/core/jobs;${Akonadi_SOURCE_DIR}/src/core/models;${Akonadi_SOURCE_DIR}/src/core/attributes>")
......@@ -360,7 +375,18 @@ install(FILES
qtest_akonadi.h
itempayloadinternals_p.h
${Akonadi_BINARY_DIR}/config-akonadi.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiCore COMPONENT Devel
DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}/akonadi
COMPONENT Devel
)
install(FILES
${AkonadiCore_base_CC_HEADERS}
${AkonadiCore_attributes_CC_HEADERS}
${AkonadiCore_models_CC_HEADERS}
${AkonadiCore_jobs_CC_HEADERS}
${AkonadiCore_CC_HEADERS}
DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}/Akonadi
COMPONENT Devel
)
install(FILES
......
# base install include dir
set(AkonadiCore_INSTALL_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiCore")
add_library(akonadi_shared STATIC)
target_sources(akonadi_shared PRIVATE
akapplication.cpp
......@@ -18,15 +21,22 @@ PUBLIC
KF5::Crash
)
ecm_generate_headers(shared_HEADERS
akonadi_generate_headers_with_deprecated(shared_CC_HEADERS
HEADER_NAMES
VectorHelper
REQUIRED_HEADERS shared_HEADERS
DEPRECATED_DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}
)
# shared is not generally a public library, so install only the useful
# public stuff to core
install(FILES
${shared_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiCore COMPONENT Devel
DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}/akonadi
COMPONENT Devel
)
install(FILES
${shared_CC_HEADERS}
DESTINATION ${AkonadiCore_INSTALL_INCLUDEDIR}/Akonadi
COMPONENT Devel
)
......@@ -10,6 +10,9 @@ endif()
configure_file(akonadiwidgetstests_export.h.in "${CMAKE_CURRENT_BINARY_DIR}/akonadiwidgetstests_export.h")
# base install include dir
set(AkonadiWidgets_INSTALL_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiWidgets")
add_library(KF5AkonadiWidgets)
add_library(KF5::AkonadiWidgets ALIAS KF5AkonadiWidgets)
......@@ -78,7 +81,7 @@ set(akonadiwidgets_UI
tagwidget.ui
)
ecm_generate_headers(AkonadiWidgets_HEADERS
akonadi_generate_headers_with_deprecated(AkonadiWidgets_CC_HEADERS
HEADER_NAMES
AgentActionManager
AgentConfigurationDialog
......@@ -109,6 +112,7 @@ ecm_generate_headers(AkonadiWidgets_HEADERS
TagWidget
TagSelectWidget
REQUIRED_HEADERS AkonadiWidgets_HEADERS
DEPRECATED_DESTINATION ${AkonadiWidgets_INSTALL_INCLUDEDIR}
)
ki18n_wrap_ui(KF5AkonadiWidgets ${akonadiwidgets_UI})
......@@ -119,7 +123,7 @@ endif()
generate_export_header(KF5AkonadiWidgets BASE_NAME akonadiwidgets)
target_include_directories(KF5AkonadiWidgets INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiWidgets>")
target_include_directories(KF5AkonadiWidgets INTERFACE "$<INSTALL_INTERFACE:${AkonadiWidgets_INSTALL_INCLUDEDIR}>")
target_link_libraries(KF5AkonadiWidgets
PUBLIC
......@@ -156,7 +160,13 @@ install(TARGETS
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/akonadiwidgets_export.h
${AkonadiWidgets_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/AkonadiWidgets COMPONENT Devel
DESTINATION ${AkonadiWidgets_INSTALL_INCLUDEDIR}/akonadi
COMPONENT Devel
)
install(FILES
${AkonadiWidgets_CC_HEADERS}
DESTINATION ${AkonadiWidgets_INSTALL_INCLUDEDIR}/Akonadi
COMPONENT Devel
)
install(FILES
......
......@@ -6,8 +6,9 @@
#pragma once
#include "agentinstance.h"
#include "akonadiwidgets_export.h"
// AkonadiCore
#include <akonadi/agentinstance.h>
#include <QObject>
......
......@@ -7,8 +7,9 @@
#pragma once
#include "agenttype.h"
#include "agenttypewidget.h"
// AkonadiCore
#include <akonadi/agenttype.h>
#include <QDialog>
......
......@@ -7,7 +7,8 @@
#pragma once
#include "akonadiwidgets_export.h"
#include "collection.h"
// AkonadiCore
#include <akonadi/collection.h>
#include <QComboBox>
......
......@@ -8,7 +8,8 @@
#pragma once
#include "akonadiwidgets_export.h"
#include "collection.h"
// AkonadiCore
#include <akonadi/collection.h>
#include <QAbstractItemView>
#include <QDialog>
......
......@@ -7,8 +7,10 @@
#pragma once
#include "akonadiwidgets_export.h"
#include "collection.h"
#include "collectiondialog.h"
// AkonadiCore
#include <akonadi/collection.h>
#include <QWidget>
namespace Akonadi
......
......@@ -10,8 +10,9 @@
#include <KConfigViewStateSaver>
#include "collection.h"
#include "item.h"
// AkonadiCore
#include <akonadi/collection.h>
#include <akonadi/item.h>
#include "akonadiwidgets_export.h"
......
......@@ -8,10 +8,11 @@
#include "akonadiwidgets_export.h"
#include <QObject>
// AkonadiCore
#include <akonadi/collection.h>
#include <akonadi/item.h>
#include "collection.h"
#include "item.h"
#include <QObject>
class QAction;
class KActionCollection;
......
......@@ -9,7 +9,9 @@
#pragma once
#include "akonadiwidgets_export.h"
#include "tag.h"
// AkonadiCore
#include <akonadi/tag.h>
#include <QWidget>
namespace Akonadi
......
......@@ -9,8 +9,9 @@
#pragma once
#include "akonadiwidgets_export.h"
// AkonadiCore
#include <akonadi/tag.h>
#include "tag.h"
#include <QDialog>
class QDialogButtonBox;
namespace Akonadi
......
......@@ -9,7 +9,8 @@
#include "akonadiwidgets_export.h"
#include "tag.h"
// AkonadiCore
#include <akonadi/tag.h>
#include <QComboBox>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment