1 # If libutempter is not available on the system, we build
2 # kwrited as an executable that is installed with setuid root
3 # (or setgid utmp) in order to be able to login successfully
4 # (and thus be useful, as kwrited does not work at all if it
5 # cannot login to the terminal device that it opens).
6 # This is required (at least) on Debian and its derivatives and
7 # opensolaris (afaict).
9 # This check is not very nice... what we should really check is
10 # whether libkpty was built with utempter support or not.
11 # This is the same check that libkpty does, so, assuming that
12 # kdebase/workspace is being built on the same system that libkpty was
13 # built, this should tell us if likpty was built with utempter or not.
14 check_library_exists(utempter addToUtmp "" HAVE_ADDTOUTEMP)
15 check_include_files(utempter.h HAVE_UTEMPTER_H)
16 if (NOT HAVE_ADDTOUTEMP OR NOT HAVE_UTEMPTER_H)
17 set(BUILD_AS_EXECUTABLE 1)
18 endif (NOT HAVE_ADDTOUTEMP OR NOT HAVE_UTEMPTER_H)
20 configure_file(config-kwrited.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwrited.h)
22 if (BUILD_AS_EXECUTABLE)
23 kde4_add_executable(kwrited kwrited.cpp)
24 target_link_libraries(kwrited ${KDE4_KDEUI_LIBS} ${KDE4_KPTY_LIBS})
25 install(TARGETS kwrited ${INSTALL_TARGETS_DEFAULT_ARGS} )
27 set(KWRITED_PATH \"\$ENV{DESTDIR}${BIN_INSTALL_DIR}/kwrited\")
29 # On Debian we setgid instead of setuid.
30 # Feel free to add checks here for other distros as well, if needed.
31 if (EXISTS /etc/debian_version)
33 set(SETGID_GROUP utmp)
34 endif (EXISTS /etc/debian_version)
37 execute_process(COMMAND sh -c \"chgrp \${SETGID_GROUP} '\${KWRITED_PATH}' && chmod g+s '\${KWRITED_PATH}'\")
39 execute_process(COMMAND sh -c \"chown root '\${KWRITED_PATH}' && chmod u+s '\${KWRITED_PATH}'\")
43 install(FILES kwrited-autostart.desktop DESTINATION ${AUTOSTART_INSTALL_DIR})
44 else (BUILD_AS_EXECUTABLE)
45 kde4_add_plugin(kded_kwrited kwrited.cpp)
46 target_link_libraries(kded_kwrited ${KDE4_KDEUI_LIBS} ${KDE4_KPTY_LIBS})
47 install(TARGETS kded_kwrited DESTINATION ${PLUGIN_INSTALL_DIR} )
49 install(FILES kwrited.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
50 endif (BUILD_AS_EXECUTABLE)
52 # The .notifyrc file is common
53 install(FILES kwrited.notifyrc DESTINATION ${DATA_INSTALL_DIR}/kwrited)