macro_optional_find_package(OpenSSL)
macro_log_feature(OPENSSL_FOUND "OpenSSL" "A toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols" "http://openssl.org" FALSE "" "Required for the Kopete Gadu-Gadu protocol.")

# On Solaris, some of the name resolution functions are in libnsl;
# this needs to be linked in if found. Copied from kdelibs.
check_library_exists(nsl gethostbyname "" HAVE_NSL_LIBRARY)

option(WITH_testbed "Enable Kopete testbed protocol" ON)
option(WITH_messenger "Enable Kopete MSN/Windows Live Messenger protocol" OFF)
option(WITH_msn "Enable Kopete MSN protocol" OFF)
option(WITH_oscar "Enable Kopete Oscar (ICQ and AIM) protocol" ON)
option(WITH_yahoo "Enable Kopete Yahoo protocol" ON)
option(WITH_qq "Enable Kopete QQ protocol" ON)
option(WITH_sms "Enable Kopete SMS protocol" ON)
option(WITH_groupwise "Enable Novell GroupWise Messenger protocol" ON)
option(WITH_telepathy "Enable Telepathy testbed protocol" OFF)
option(WITH_winpopup "Enable Kopete winpopup protocol" ON)
option(WITH_gadu "Enable Kopete Gadu-Gadu protocol" ON)
option(WITH_jabber "Enable Kopete Jabber protocol" ON)
option(WITH_bonjour "Enable Kopete Bonjour protocol" ON)
option(WITH_irc "Enable Kopete IRC protocol" OFF)
option(WITH_wlm "Enable Window Live Messenger support" ON)
option(WITH_meanwhile "Enable Kopete meanwhile protocol" ON)

include_directories(${KOPETE_INCLUDES})

if(WITH_wlm AND LIBMSN_FOUND)
  add_subdirectory( wlm )
endif(WITH_wlm AND LIBMSN_FOUND)

if(WITH_msn)
  add_subdirectory( msn ) 
endif(WITH_msn)
if(WITH_oscar)
  add_subdirectory( oscar )
endif(WITH_oscar)
if(WITH_yahoo)
  add_subdirectory( yahoo ) 
endif(WITH_yahoo)
if(WITH_qq)
  add_subdirectory( qq )
endif(WITH_qq)
if(WITH_irc)
  message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}: WARNING: Building the irc plugin, even if  it hasn't been completely ported yet")
  add_subdirectory( irc )
endif(WITH_irc)
if(NOT WIN32)
  if(WITH_winpopup)
    add_subdirectory( winpopup )
  endif(WITH_winpopup)
  if(WITH_gadu AND OPENSSL_FOUND)
	add_subdirectory( gadu )
  endif(WITH_gadu AND OPENSSL_FOUND)
  if(WITH_sms)
    add_subdirectory( sms )
  endif(WITH_sms)
endif(NOT WIN32)

if(WITH_messenger)
  add_subdirectory( messenger )
endif(WITH_messenger)

if(QCA2_FOUND)
  if(IDN_FOUND)
    if(WITH_jabber)
      add_subdirectory( jabber )
    endif(WITH_jabber)
  else(IDN_FOUND)
    message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}: Disabled Jabber because libidn-devel was not found")
  endif(IDN_FOUND)
  if(WITH_groupwise)
    add_subdirectory( groupwise )
  endif(WITH_groupwise)
else(QCA2_FOUND)
  message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}: Disabled GroupWise and Jabber because QCA2 was not found")
endif(QCA2_FOUND)

if(WITH_testbed)
  add_subdirectory( testbed )
endif(WITH_testbed)

if(WITH_telepathy AND DECIBEL_FOUND)
  add_subdirectory( telepathy )
endif(WITH_telepathy AND DECIBEL_FOUND)

if(WITH_bonjour)
  add_subdirectory( bonjour )
endif(WITH_bonjour)

if(WITH_meanwhile)
  if(LIBMEANWHILE_FOUND)
    add_subdirectory( meanwhile )
  else(LIBMEANWHILE_FOUND)
    message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}: Disabled Meanwhile beause libmeanwhile was not found")
  endif(LIBMEANWHILE_FOUND)
endif(WITH_meanwhile)
