Index: KDE4Macros.cmake
===================================================================
--- KDE4Macros.cmake	(revision 793929)
+++ KDE4Macros.cmake	(working copy)
@@ -747,6 +747,65 @@
 
 endmacro (KDE4_ADD_KDEINIT_EXECUTABLE)
 
+# the following macros are intended for creating kdeinit modules using with a 
+# platform independent interface 
+# kdeinit modules are shared libraries loadable by the kdeinit loader 
+# on win32 kdeinit modules are not supported and replaced by simple executables  
+# 
+#kde4_kdeinit_add_executable(target options sources)
+#kde4_kdeinit_link_libraries(target options libraries)
+#kde4_kdeinit_install(target options)
+
+# th 'if' statement is made outside the macros to reduce the number of conditionals 
+# it could be extended to whole KDE4Macros.cmake to split it into three 
+# areas - a platform independent, a win32, a unix and a mac os specific section 
+if (WIN32)
+    macro (kde4_kdeinit_add_executable _target_NAME)
+        add_definitions(-Dkdemain=main)
+        kde4_check_executable_params(_SRCS _nogui _uninst _test ${ARGN})
+        kde4_add_executable(${_target_NAME} "${_nogui}" "${_uninst}" ${_SRCS})
+    endmacro (kde4_kdeinit_add_executable)
+    
+    macro (kde4_kdeinit_link_libraries _target_NAME)
+        target_link_libraries(${_target_NAME} ${ARGN})
+    endmacro (kde4_kdeinit_link_libraries)
+    
+    macro (kde4_kdeinit_install)
+        install(TARGETS ${ARGV})
+    endmacro (kde4_kdeinit_install)
+else(WIN32)
+    macro (kde4_kdeinit_add_executable _target_NAME)
+       kde4_check_executable_params(_SRCS _nogui _uninst _test ${ARGN})
+    
+       set (KDEINIT_LINK_TYPE SHARED)
+    
+       kde4_handle_automoc(kdeinit_${_target_NAME} _SRCS)
+       if (KDE4_ENABLE_FINAL)
+          kde4_create_final_files(${CMAKE_CURRENT_BINARY_DIR}/kdeinit_${_target_NAME}_final_cpp.cpp _separate_files ${_SRCS})
+          add_library(kdeinit_${_target_NAME} ${KDEINIT_LINK_TYPE} ${CMAKE_CURRENT_BINARY_DIR}/kdeinit_${_target_NAME}_final_cpp.cpp ${_separate_files})
+    
+       else (KDE4_ENABLE_FINAL)
+          add_library(kdeinit_${_target_NAME} ${KDEINIT_LINK_TYPE} ${_SRCS})
+       endif (KDE4_ENABLE_FINAL)
+    
+       kde4_handle_rpath_for_library(kdeinit_${_target_NAME})
+       set_target_properties(kdeinit_${_target_NAME} PROPERTIES OUTPUT_NAME kdeinit4_${_target_NAME})
+    
+       configure_file(${KDE4_MODULE_DIR}/kde4init_dummy.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp)
+       kde4_add_executable(${_target_NAME} "${_nogui}" "${_uninst}" ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp)
+    endmacro (kde4_kdeinit_add_executable)
+    
+    macro (kde4_kdeinit_link_libraries _target_NAME)
+       target_link_libraries(kdeinit_${_target_NAME} ${ARGN})
+       target_link_libraries(${_target_NAME} kdeinit_${_target_NAME})
+    endmacro (kde4_kdeinit_link_libraries)
+    
+    macro (kde4_kdeinit_install _target_NAME)
+        install(TARGETS kdeinit_${_target_NAME} ${INSTALL_TARGETS_DEFAULT_ARGS} )
+        install(TARGETS ${_target_NAME} ${ARGN})
+    endmacro (kde4_kdeinit_install)
+endif (WIN32)
+
 # add a unit test, which is executed when running make test
 # it will be built with RPATH pointing to the build dir
 # The targets are always created, but only built for the "all"