
if(${KDE_PLATFORM_PROFILE} STREQUAL "Desktop")
add_subdirectory( kcm )
endif(${KDE_PLATFORM_PROFILE} STREQUAL "Desktop")
add_subdirectory( tests )

include_directories(
   ${KDEBASE_WORKSPACE_SOURCE_DIR}/libs
   ${QIMAGEBLITZ_INCLUDES}
)

check_library_exists(ICE _IceTransNoListen "" HAVE__ICETRANSNOLISTEN)
configure_file(config-ksmserver.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksmserver.h)

########### next target ###############

set(ksmserver_KDEINIT_SRCS
   main.cpp
   server.cpp
   shutdowndlg.cpp
   legacy.cpp
   startup.cpp
   shutdown.cpp
   client.cpp
   logouteffect.cpp
   fadeeffect.cpp
   curtaineffect.cpp)

INCLUDE(CheckCCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-mmmx HAVE_MMMX)

if (HAVE_MMMX)
   SET_SOURCE_FILES_PROPERTIES(fadeeffect.cpp PROPERTIES COMPILE_FLAGS -mmmx)
endif (HAVE_MMMX)

set(kcminit_adaptor ${CMAKE_CURRENT_SOURCE_DIR}/../kcminit/main.h)
set(kcminit_xml ${CMAKE_CURRENT_BINARY_DIR}/org.kde.KCMinit.xml)
add_custom_command(OUTPUT ${kcminit_xml}
       COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${kcminit_adaptor} > ${kcminit_xml}
       DEPENDS ${kcminit_adaptor})
qt4_add_dbus_interface( ksmserver_KDEINIT_SRCS ${kcminit_xml} kcminit_interface )

# This is actually now disabled, because OrgKDEKlauncherInterface is also provided
# by kdecore, it is not autogenerated and is not binary compatible with a currently
# generated version, thus at certain circumstances leading to strange crashes.
# This should be fixed for KDE5.
# KLauchner.xml is installed by kdelibs, so it is in KDE4_DBUS_INTERFACES_DIR
# set(klauncher_xml  ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KLauncher.xml)
# qt4_add_dbus_interface( ksmserver_KDEINIT_SRCS ${klauncher_xml} klauncher_interface )

qt4_add_dbus_adaptor( ksmserver_KDEINIT_SRCS org.kde.KSMServerInterface.xml server.h KSMServer )

kde4_add_kdeinit_executable( ksmserver ${ksmserver_KDEINIT_SRCS})

target_link_libraries(kdeinit_ksmserver ${KDE4_PLASMA_LIBS} kworkspace
   ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${QIMAGEBLITZ_LIBRARIES} ${KDE4_SOLID_LIBS} ${X11_LIBRARIES} ${X11_Xrender_LIB}
)

install(TARGETS kdeinit_ksmserver ${INSTALL_TARGETS_DEFAULT_ARGS})

install(TARGETS ksmserver ${INSTALL_TARGETS_DEFAULT_ARGS})

########### next target ###############

set(kcheckrunning_SRCS
   kcheckrunning.cpp)

kde4_add_executable( kcheckrunning ${kcheckrunning_SRCS})

target_link_libraries(kcheckrunning ${X11_LIBRARIES})

install(TARGETS kcheckrunning ${INSTALL_TARGETS_DEFAULT_ARGS})

########### install files ###############

install( FILES ksmserver.upd ksmserver_shortcuts.upd DESTINATION  ${KCONF_UPDATE_INSTALL_DIR} )
install( PROGRAMS move_session_config.sh DESTINATION  ${KCONF_UPDATE_INSTALL_DIR} )
install( FILES org.kde.KSMServerInterface.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
