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)

# 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(IW)
find_package(JPEG)
find_package(X11VidMode)
find_package(Decibel)
find_package(IDN)

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

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 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(IW_FOUND      "libiw"    "Wireless Tools are needed to build wifi project" "http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html")
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 ( -DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
add_definitions (${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})

add_subdirectory(doc)
add_subdirectory(kfile-plugins)
add_subdirectory(lanbrowsing)
add_subdirectory(cmake)

if(Q_WS_X11)
  add_subdirectory(knewsticker)
  add_subdirectory(kppp)

  #add_subdirectory(kpf)
  if(JPEG_FOUND AND SLP_FOUND)

    if(X11VIDMODE_FOUND)
       add_subdirectory(krdc)
    endif(X11VIDMODE_FOUND)

    if(X11_XTest_FOUND)
       add_subdirectory(krfb)
    endif(X11_XTest_FOUND)

  endif(JPEG_FOUND AND SLP_FOUND)
endif(Q_WS_X11)

if (DNSSD_FOUND)
   add_subdirectory(kdnssd)
endif (DNSSD_FOUND)

if (QCA2_FOUND)
   add_subdirectory(kopete)
endif (QCA2_FOUND)

if (IW_FOUND)
   add_subdirectory(wifi)
endif (IW_FOUND)

message(STATUS "TODO: port kpf!")
add_subdirectory(filesharing)
add_subdirectory(kdict)

macro_display_feature_log()
