#################################################
#
#  (C) 2016 Slávek Banko
#  slavek.banko (AT) axis.cz
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 2.8 )


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

project( tellico )
set( VERSION 1.3.6 )


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

include( FindPkgConfig )
include( CheckIncludeFile )
include( CheckLibraryExists )
include( CheckSymbolExists )
include( CheckTypeSize )
# EXAMPLE:
# include( CheckCSourceCompiles )
# include( CheckCXXSourceCompiles )

enable_testing()


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

set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( TDEMacros )


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

include( TDESetupPaths )
tde_setup_paths( )


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

option( WITH_ALL_OPTIONS   "Enable all sane supported options" OFF )

option( WITH_LIBKCDDB      "Enable FreeDB integration" ${WITH_ALL_OPTIONS} )
option( WITH_LIBKCAL       "Enable KOrganizer integration" ${WITH_ALL_OPTIONS} )
option( WITH_LIBBTPARSE    "Use btparse shared library" ${WITH_ALL_OPTIONS} )
option( WITH_SAX_LOADER    "Use SAX document loading (experimental)" ${WITH_ALL_OPTIONS} )


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

# WITH_LIBKCDDB       enable searching via freedb
# WITH_LIBKCAL        enable integration with KOrganizer
# WITH_LIBBTPARSE     if enabled use system library btparse instead of build-in
# WITH_SAX_LOADER     if enabled documents will be openned using SAX loader


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

option( BUILD_DOC "Build documentation" ON )
option( BUILD_TRANSLATIONS "Build translations" ON )
option( BUILD_XMLCATALOG "" OFF )

option( BUILD_AMAZON_SUPPORT "Build Amazon.com searching support" ON )
option( BUILD_IMDB_SUPPORT "Build IMDb searching support" ON )
option( BUILD_CDTEXT_SUPPORT "Build CD-Text support (Linux only)" ON )
option( BUILD_OOO_SUPPORT "Build LibreOffice/OpenOffice.org support" OFF )
option( BUILD_EXEMPI_SUPPORT "Build exempi support" ON )
option( BUILD_POPPLER_SUPPORT "Build poppler support" ON )
option( BUILD_WEBCAM_SUPPORT "Build support for scanning barcodes (experimental)" ON )


##### 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" )


##### tellico directories #######################

add_subdirectory( src )
add_subdirectory( icons )
add_subdirectory( xslt )
tde_conditional_add_subdirectory( BUILD_TRANSLATIONS po )
tde_conditional_add_subdirectory( BUILD_DOC doc )


##### other data ################################

install( FILES tellico.desktop
  DESTINATION ${XDG_APPS_INSTALL_DIR}
)
install( FILES tellico.xml
  DESTINATION ${XDG_MIME_INSTALL_DIR}
)
install( FILES x-tellico.desktop
  DESTINATION ${MIME_INSTALL_DIR}/application
)
install( FILES tellico.dtd tellico.tips
  DESTINATION ${DATA_INSTALL_DIR}/${CMAKE_PROJECT_NAME}
)


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

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