project( kdeutils )

set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )

# search packages used by KDE
find_package( KDE4 REQUIRED )
find_package( Blitz )
find_package( KdepimLibs REQUIRED )
include( KDE4Defaults )
include( MacroLibrary )
include( MacroOptionalAddSubdirectory )

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

add_definitions( ${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS} )
include_directories( ${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} )

add_subdirectory( cmake )

# --- check for dependencies ---
macro_optional_find_package( GMP )
macro_log_feature( GMP_FOUND "GMP" "The GNU Multiple Precision Arithmetic Library" "http://www.swox.com/gmp" FALSE "" "Required for building KCalc.")

# --- docs ---
macro_optional_add_subdirectory( doc )

# --- programs ---
# listed alphabetically, each with own guards
macro_optional_add_subdirectory( ark )
if( GMP_FOUND )
   macro_optional_add_subdirectory( kcalc )
endif( GMP_FOUND )
macro_optional_add_subdirectory( kcharselect )
if( UNIX )
   macro_optional_add_subdirectory( kdessh )
endif( UNIX )
if( UNIX )
   macro_optional_add_subdirectory( kdf )
endif( UNIX )
if( NOT WIN32 )
  # K3Process
  macro_optional_add_subdirectory( kfloppy )
endif( NOT WIN32 )
macro_optional_add_subdirectory( kgpg )
macro_optional_add_subdirectory( ktimer )
macro_optional_add_subdirectory( kwallet )
macro_optional_add_subdirectory( okteta )
if( NOT WIN32 )
  macro_optional_add_subdirectory( printer-applet )
endif( NOT WIN32 )
if( Q_WS_X11 AND BLITZ_FOUND )
    #find_file( BACKGROUND_INTERFACE_FILE_FOUND org.kde.kdesktop.Background.xml PATHS ${DBUS_INTERFACES_INSTALL_DIR} )

    #if( BACKGROUND_INTERFACE_FILE_FOUND )
        macro_optional_add_subdirectory( superkaramba )
    #else( BACKGROUND_INTERFACE_FILE_FOUND )
        #MESSAGE( STATUS "org.kde.kdesktop.Background.xml was not found install kdebase before please" )
    #endif( BACKGROUND_INTERFACE_FILE_FOUND )
endif( Q_WS_X11 AND BLITZ_FOUND )
macro_optional_add_subdirectory( sweeper )

# --- show log ---
macro_display_feature_log()
