project(kdenetwork)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )

# search packages used by KDE
find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include (MacroLibrary)

include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckPrototypeExists)
include(CheckTypeSize)
include(MacroBoolTo01)
include(MacroOptionalAddSubdirectory)

# If definitions like -D_GNU_SOURCE are needed for these checks they
# should be added to _KDE4_PLATFORM_DEFINITIONS when it is originally
# defined outside this file.  Here we include these definitions in
# CMAKE_REQUIRED_DEFINITIONS so they will be included in the build of
# checks below.
set(CMAKE_REQUIRED_DEFINITIONS ${_KDE4_PLATFORM_DEFINITIONS})
if (WIN32)
   set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES} )
   set(CMAKE_REQUIRED_INCLUDES  ${KDEWIN32_INCLUDES} )
endif (WIN32)

find_package(KdepimLibs REQUIRED)
find_package(QCA2)
find_package(JPEG)
find_package(X11VidMode)
find_package(Decibel)

macro_optional_find_package(DNSSD)
macro_optional_find_package(SLP)
macro_optional_find_package(IDN)
macro_optional_find_package(LibVNCServer)

macro_log_feature(LIBVNCSERVER_FOUND   "libvncserver" "VNC Server lib, needed to build krfb"       "http://libvncserver.sourceforge.net/")
macro_log_feature(DNSSD_FOUND   "libdnssd" "Support for Zeroconf, needed to build dnssd"       "http://www.zeroconf.org")
macro_log_feature(QCA2_FOUND    "libqca2"  "Qca2 is needed to build some parts of kopete"              "Module into kdesupport" FALSE "2.0")
macro_log_feature(SLP_FOUND     "openslp"  "OpenSLP is needed to build krdc and krfb"         "http://www.openslp.org/")
macro_log_feature(DECIBEL_FOUND "Decibel"  "Decibel is the KDE framework for real-time communication" "HOWTO in kopete/protocols/telepathy")
macro_log_feature(IDN_FOUND   "libidn" "libidn provides International Domain Name Support for Kopete's Jabber plugin"       "http://www.gnu.org/software/libidn")

macro_bool_to_01(SLP_FOUND HAVE_SLP) # for both krfb and krdc

add_definitions (${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})

macro_optional_add_subdirectory(doc)
macro_optional_add_subdirectory(kfile-plugins)
macro_optional_add_subdirectory(lanbrowsing)
macro_optional_add_subdirectory(kget)

if(Q_WS_X11)

  #find_package(Plasma)
  #  macro_log_feature(PLASMA_FOUND "Plasma" "Plasma is a really cool replacement for kicker, needed for KNewsTicker" "Part of kdebase")
  #if(PLASMA_FOUND)
     #    macro_optional_add_subdirectory(knewsticker)
  #endif(PLASMA_FOUND)

  macro_optional_add_subdirectory(kppp)

  if(LIBVNCSERVER_FOUND AND SLP_FOUND)
    macro_optional_add_subdirectory(krfb)
  endif(LIBVNCSERVER_FOUND AND SLP_FOUND)

endif(Q_WS_X11)

macro_optional_add_subdirectory(krdc)

if (DNSSD_FOUND)
   macro_optional_add_subdirectory(kdnssd)
endif (DNSSD_FOUND)

macro_optional_add_subdirectory(kopete)

if(NOT WIN32)
  macro_optional_add_subdirectory(filesharing)
endif(NOT WIN32)

macro_display_feature_log()
