@PACKAGE_INIT@

# This needs to be set before finding dependencies, since it uses
# PACKAGE_PREFIX_DIR, which may be overwritten by the config files
# of other packages.
set(KDE4_DBUS_INTERFACES_DIR "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@")

include(CMakeFindDependencyMacro)
find_dependency(KF5Auth "@KF5_DEP_VERSION@")
find_dependency(KF5Archive "@KF5_DEP_VERSION@")
find_dependency(KF5ConfigWidgets "@KF5_DEP_VERSION@")
find_dependency(KF5CoreAddons "@KF5_DEP_VERSION@")
find_dependency(KF5Crash "@KF5_DEP_VERSION@")
find_dependency(KF5DesignerPlugin "@KF5_DEP_VERSION@")
find_dependency(KF5DocTools "@KF5_DEP_VERSION@")
find_dependency(KF5Emoticons "@KF5_DEP_VERSION@")
find_dependency(KF5GuiAddons "@KF5_DEP_VERSION@")
find_dependency(KF5IconThemes "@KF5_DEP_VERSION@")
find_dependency(KF5ItemModels "@KF5_DEP_VERSION@")
find_dependency(KF5Init "@KF5_DEP_VERSION@")
find_dependency(KF5Notifications "@KF5_DEP_VERSION@")
find_dependency(KF5Parts "@KF5_DEP_VERSION@")
find_dependency(KF5TextWidgets "@KF5_DEP_VERSION@")
find_dependency(KF5UnitConversion "@KF5_DEP_VERSION@")
find_dependency(KF5WindowSystem "@KF5_DEP_VERSION@")
find_dependency(KF5DBusAddons "@KF5_DEP_VERSION@")

find_dependency(Qt5DBus @REQUIRED_QT_VERSION@)
find_dependency(Qt5Xml @REQUIRED_QT_VERSION@)
find_dependency(Qt5PrintSupport @REQUIRED_QT_VERSION@)

if(WIN32)
    find_dependency(KDEWin)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/KF5KDELibs4SupportTargets.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/ECMQt4To5Porting.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/KDE4Macros.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/MacroAppendIf.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/MacroEnsureOutOfSourceBuild.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/MacroBoolTo01.cmake")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

remove_definitions(
  -DQT_NO_SIGNALS_SLOTS_KEYWORDS
  -DQT_NO_CAST_FROM_ASCII
  -DQT_NO_CAST_TO_ASCII
)

# This is not intended to be a list of what frameworks each of the kde libraries
# was broken into. KDE4_KDECORE_LIBS contains more than what used to be in
# the kdecore library. That is a feature. These things should be big ugly warts
# in any project using them. The KDELibs4Support module is not for long term use and
# it is not for 'making code build with both Qt/KDE 4 and Qt/KF 5' for medium or
# long term. In trivial cases, no use of KDELibs4Support will be pushed to the repo
# of the code being ported.
#
# The use-sequence is this:
# 1. When starting to port something to KF5, find and use KDELibs4Support.
# 2. Port the C++ code to Qt5/KF5.
# 3. Port the buildsystem away from KDELibs4Support.
# 4. Remove the find_package for KDELibs4Support.

set(KDE4_KDECORE_LIBS
  KF5::KDELibs4Support
  Qt5::Network
  Qt5::DBus
  Qt5::Xml
  KF5::KIOCore
  KF5::I18n
  KF5::CoreAddons
  KF5::Codecs
  KF5::ConfigCore
  KF5::WidgetsAddons
  KF5::ItemModels
  KF5::ConfigWidgets
  KF5::Completion
  KF5::XmlGui
  KF5::IconThemes
  KF5::KIOWidgets
  KF5::ItemViews
  KF5::Emoticons
)
set(KDE4_KDEUI_LIBS  ${KDE4_KDECORE_LIBS})
set(KDE4_KIO_LIBS ${KDE4_KDECORE_LIBS})
set(KDE4_KPARTS_LIBS ${KDE4_KPARTS_LIBS})
set(KDE4_KUTILS_LIBS ${KDE4_KUTILS_LIBS})
set(KDE4_KFILE_LIBS ${KDE4_KFILE_LIBS})
set(KDE4_KHTML_LIBS ${KDE4_KHTML_LIBS})
set(KDE4_KDELIBS4SUPPORT_LIBS  ${KDE4_KDECORE_LIBS})

set(KDE4_INCLUDES $<TARGET_PROPERTY:KF5::KDELibs4Support,INTERFACE_INCLUDE_DIRECTORIES>)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"))
  set (KDE4_ENABLE_EXCEPTIONS -EHsc)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  set (KDE4_ENABLE_EXCEPTIONS "-fexceptions -UQT_NO_EXCEPTIONS")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
  set (KDE4_ENABLE_EXCEPTIONS -fexceptions)
endif()
