project(kdeedu)

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

# search packages used by KDE
find_package(KDE4 4.3.80 REQUIRED)
if(WIN32)
  find_package(KDEWIN32 REQUIRED)
  # detect oxygen icon dir at configure time based on KDEDIRS - there may be different package installation locations
  execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path icon OUTPUT_VARIABLE _dir ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  file(TO_CMAKE_PATH "${_dir}" __dir)
  find_path(KDE4_ICON_DIR oxygen PATHS
      ${__dir}
  )
  message(STATUS "using oxygen application icons from ${KDE4_ICON_DIR}")
else(WIN32)
    set (KDE4_ICON_DIR  ${CMAKE_INSTALL_PREFIX}/share/icons)
endif(WIN32)

#### Python support ####
set(PythonSupport_FOUND FALSE)

macro_log_feature(EXPERIMENTAL_PYTHON_BINDINGS "Experimental Python binding support for the Marble library" "Experimental Python binding support for the Marble library"
  "http://techbase.kde.org/Development/Languages/Python" FALSE ""
  "Experimental Python binding support for the Marble library. To activate it pass -DEXPERIMENTAL_PYTHON_BINDINGS=TRUE to cmake.")

if(EXPERIMENTAL_PYTHON_BINDINGS)
    macro_optional_find_package(PythonLibrary)

    macro_optional_find_package(SIP)
    if(SIP_FOUND AND SIP_VERSION STRLESS "040701")
        message(STATUS "The version of SIP found is too old. 4.7.1 or later is needed.")
        set(SIP_FOUND)
    endif(SIP_FOUND AND SIP_VERSION STRLESS "040701")

    include(SIPMacros)

    macro_optional_find_package(PyQt4)
    if(PYQT4_FOUND AND PYQT4_VERSION STRLESS "040400")
        message(STATUS "The version of PyQt found is too old. 4.4.0 or later is required.")
        set(PYQT4_FOUND)
    endif(PYQT4_FOUND AND PYQT4_VERSION STRLESS "040400")
    macro_log_feature(PYQT4_FOUND "PyQt4" "PyQt4 was not found.  It is needed by marble python plugins to run. " "http://www.riverbankcomputing.co.uk/software/pyqt/intro" FALSE)

    macro_optional_find_package(PyKDE4)
    if (PYTHONLIBRARY_FOUND AND SIP_FOUND AND PYQT4_FOUND AND PYKDE4_FOUND)
      set(PythonSupport_FOUND TRUE)
    endif (PYTHONLIBRARY_FOUND AND SIP_FOUND AND PYQT4_FOUND AND PYKDE4_FOUND)

    macro_log_feature(PythonSupport_FOUND "Python" "KDE Python support"
      "http://techbase.kde.org/Development/Languages/Python" FALSE ""
      "Needed for Python bindings to the marble widget.")
endif(EXPERIMENTAL_PYTHON_BINDINGS)

#### End Python support ####

include(KDE4Defaults)
include(MacroLibrary)
include(MacroOptionalAddSubdirectory)
include(MacroBoolTo01)

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

add_subdirectory(cmake)
add_subdirectory(data)
add_subdirectory(libkdeedu)
macro_optional_add_subdirectory(blinken)
macro_optional_add_subdirectory(kanagram)
macro_optional_add_subdirectory(kbruch)
macro_optional_add_subdirectory(kgeography)
macro_optional_add_subdirectory(khangman)
macro_optional_add_subdirectory(kig)
macro_optional_add_subdirectory(kiten)
macro_optional_add_subdirectory(klettres)
macro_optional_add_subdirectory(kmplot)
macro_optional_add_subdirectory(kstars)
macro_optional_add_subdirectory(ktouch)
macro_optional_add_subdirectory(kturtle)
macro_optional_add_subdirectory(parley)
macro_optional_add_subdirectory(kwordquiz)
macro_optional_add_subdirectory(marble)
macro_optional_add_subdirectory(kalgebra)
macro_optional_add_subdirectory(cantor)
macro_optional_add_subdirectory(rocs)

macro_optional_find_package(Eigen2 2.0.3)
macro_log_feature(EIGEN2_FOUND "Eigen2" "A generic C++ template library for dense and sparse matrices" "http://eigen.tuxfamily.org" FALSE "2.0.3" "Required to build Step.")
macro_optional_add_subdirectory(kalzium)
if (EIGEN2_FOUND AND NOT WIN32)
  macro_optional_add_subdirectory(step)
endif (EIGEN2_FOUND AND NOT WIN32)
macro_optional_add_subdirectory(doc)
macro_display_feature_log()
