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


##### set project version ########################

include( TDEVersion )
cmake_minimum_required( VERSION ${TDE_CMAKE_MINIMUM_VERSION} )
tde_set_project_version( )


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

project( tellico )
set( PACKAGE_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 #################

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_ALL             "Build all"                                          ON )

option( BUILD_DOC             "Build documentation"                                ${BUILD_ALL} )
option( BUILD_TRANSLATIONS    "Build translations"                                 ${BUILD_ALL} )

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


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


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

tde_conditional_add_project_docs( BUILD_DOC )
tde_conditional_add_project_translations( BUILD_TRANSLATIONS )

tde_create_translated_desktop( tellico.desktop )
tde_create_translated_desktop(
  SOURCE x-tellico.desktop
  DESTINATION ${MIME_INSTALL_DIR}/application
)
tde_create_translated_desktop(
  SOURCE tellico.xml
  KEYWORDS comment
  FORMAT xml
  DESTINATION ${XDG_MIME_INSTALL_DIR}
)
install( FILES tellico.dtd tellico.tips
  DESTINATION ${DATA_INSTALL_DIR}/${CMAKE_PROJECT_NAME}
)


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

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