#################################################
#
#  (C) 2013 Alexander Golubev
#  fatzer2 (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 3.5 )


##### general package setup #####################

project( tdeaddons )


##### include essential cmake modules ###########

include( FindPkgConfig )
include( CheckIncludeFile )
include( CheckLibraryExists )
include( CheckSymbolExists )
include( CheckCXXSourceCompiles )


##### include our cmake modules #################

include( TDEMacros )


##### set version number ########################

tde_set_project_version( )


##### setup install paths #######################

include( TDESetupPaths )
tde_setup_paths( )


##### optional stuff ############################

option( WITH_ALL_OPTIONS    "Enable all sane optional stuff" OFF )
option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
option( WITH_ARTS           "Enable aRts support" ${WITH_ALL_OPTIONS} )
option( WITH_SDL            "Enable SDL support" ${WITH_ALL_OPTIONS} )
option( WITH_BERKELEY_DB    "Enable Berkeley DB support" ${WITH_ALL_OPTIONS} )
option( WITH_XMMS           "Enable xmms support" OFF )
option( WITH_TEST           "Build tests" OFF )


##### options comments ##########################

# WITH_XMMS        affects     kicker-applets
# WITH_XMMS        description enables kicker multimedia-control applet to interact
#                              with xmms
# WITH_ARTS        affects     konq-plugins/sidebar/mediaplayer, noatun plugins
# WITH_SDL         affects     noatun plugins
# WITH_BERKELEY_DB affects     noatun plugins
# WITH_TEST        affects     konq-plugins/fsview

# NOTE: WITH_XMMS supports only obsolte xmms version 1

##### user requested modules ####################

option( BUILD_ALL "Build all" OFF )

option( BUILD_ATLANTIKDESIGNER     "Build atlantikdesigner" ${BUILD_ALL} ) # need tdegames
option( BUILD_DOC                  "Build documentation" ${BUILD_ALL} )
option( BUILD_KADDRESSBOOK_PLUGINS "Build kaddressbook plugins" ${BUILD_ALL} ) # requires tdepim
option( BUILD_KATE_PLUGINS         "Build kate plugins" ${BUILD_ALL} )
option( BUILD_KICKER_APPLETS       "Build kicker applets" ${BUILD_ALL} )
option( BUILD_KNEWSTICKER_SCRIPTS  "Install additional knewsticker scripts" ${BUILD_ALL} )
option( BUILD_KONQ_PLUGINS         "Build konqueror plugins" ${BUILD_ALL} )
option( BUILD_KSIG                 "Build kde email signature manager" ${BUILD_ALL} )
option( BUILD_NOATUN_PLUGINS       "Build noatun plugins" ${BUILD_ALL} ) # need tdemultimedia
option( BUILD_RENAMEDLG_PLUGINS    "Build KRenameDlg plugins" ${BUILD_ALL} )
option( BUILD_TDEFILE_PLUGINS      "Build additional tdefileplugins" ${BUILD_ALL} )
option( BUILD_TUTORIALS            "Build tutorial help handbooks" OFF )


##### configure checks ##########################

include( ConfigureChecks.cmake )


###### global compiler settings #################

add_definitions(
  -DHAVE_CONFIG_H
)

set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" )

if( WITH_TEST )
  enable_testing()
endif( WITH_TEST )

##### tdeaddons directories #####################

tde_conditional_add_subdirectory( BUILD_ATLANTIKDESIGNER     atlantikdesigner )
tde_conditional_add_subdirectory( BUILD_DOC                  doc )
tde_conditional_add_subdirectory( BUILD_KADDRESSBOOK_PLUGINS kaddressbook-plugins )
tde_conditional_add_subdirectory( BUILD_KATE_PLUGINS         kate )
tde_conditional_add_subdirectory( BUILD_KICKER_APPLETS       kicker-applets )
tde_conditional_add_subdirectory( BUILD_KNEWSTICKER_SCRIPTS  knewsticker-scripts )
tde_conditional_add_subdirectory( BUILD_KONQ_PLUGINS         konq-plugins )
tde_conditional_add_subdirectory( BUILD_KSIG                 ksig )
tde_conditional_add_subdirectory( BUILD_NOATUN_PLUGINS       noatun-plugins )
tde_conditional_add_subdirectory( BUILD_RENAMEDLG_PLUGINS    renamedlgplugins )
tde_conditional_add_subdirectory( BUILD_TDEFILE_PLUGINS      tdefile-plugins )
tde_conditional_add_subdirectory( BUILD_TUTORIALS            tutorials )

##### write configure files #####################

configure_file( config.h.cmake config.h @ONLY )
