Merge branch 'dbus-1.8'
[platform/upstream/dbus.git] / cmake / bus / CMakeLists.txt
1 add_definitions(-DDBUS_COMPILATION)
2
3 SET(EFENCE "")
4 SET(BUS_DIR ${CMAKE_SOURCE_DIR}/../bus)
5
6 # config files for installation 
7 CONFIGURE_FILE( "${BUS_DIR}/session.conf.in" "${CMAKE_CURRENT_BINARY_DIR}/session.conf" IMMEDIATE @ONLY)
8 FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/session.d)
9
10 if(NOT WIN32)
11     CONFIGURE_FILE( "system.conf.cmake" "${CMAKE_CURRENT_BINARY_DIR}/system.conf" IMMEDIATE @ONLY)
12     FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/system.d)
13 endif()
14
15 # copy services for local daemon start to local service dir data/dbus-1/services
16 SET (SERVICE_FILES test/data/valid-service-files)
17 FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${SERVICE_FILES}/*.service.in" )
18 FOREACH(FILE ${FILES})  
19         GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME_WE)
20         SET (TARGET ${CMAKE_BINARY_DIR}/data/dbus-1/services/${FILENAME}.service)
21         IF (CONFIG_VERBOSE)
22                 MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n")
23         ENDIF (CONFIG_VERBOSE)
24         configure_file(${FILE} ${TARGET} )
25 ENDFOREACH(FILE)
26
27 SET (XML_SOURCES ${BUS_DIR}/config-loader-expat.c)
28
29 if (DBUS_BUS_ENABLE_INOTIFY)
30     set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-inotify.c)
31 elseif (DBUS_BUS_ENABLE_KQUEUE)
32     set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-kqueue.c)
33 else (DBUS_BUS_ENABLE_INOTIFY)
34     set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-default.c)
35 endif (DBUS_BUS_ENABLE_INOTIFY)
36
37 set (BUS_SOURCES 
38         ${BUS_DIR}/activation.c                         
39         ${BUS_DIR}/activation.h                         
40         ${BUS_DIR}/apparmor.c
41         ${BUS_DIR}/apparmor.h
42         ${BUS_DIR}/bus.c                                        
43         ${BUS_DIR}/bus.h                                        
44         ${BUS_DIR}/config-parser.c                              
45         ${BUS_DIR}/config-parser.h
46         ${BUS_DIR}/config-parser-common.c
47         ${BUS_DIR}/config-parser-common.h
48 #    ${BUS_DIR}/config-parser-trivial.c
49         ${BUS_DIR}/connection.c
50         ${BUS_DIR}/connection.h                         
51         ${BUS_DIR}/desktop-file.c                               
52         ${BUS_DIR}/desktop-file.h                               
53         ${BUS_DIR}/dir-watch.h                          
54         ${BUS_DIR}/dispatch.c                           
55         ${BUS_DIR}/dispatch.h                           
56         ${BUS_DIR}/driver.c                             
57         ${BUS_DIR}/driver.h                             
58         ${BUS_DIR}/expirelist.c                         
59         ${BUS_DIR}/expirelist.h                         
60         ${BUS_DIR}/policy.c                             
61         ${BUS_DIR}/policy.h                             
62         ${BUS_DIR}/selinux.h                            
63         ${BUS_DIR}/selinux.c                            
64         ${BUS_DIR}/services.c                           
65         ${BUS_DIR}/services.h                           
66         ${BUS_DIR}/signals.c                            
67         ${BUS_DIR}/signals.h                            
68         ${BUS_DIR}/test.c                                       
69         ${BUS_DIR}/test.h                                       
70         ${BUS_DIR}/utils.c                                      
71         ${BUS_DIR}/utils.h                                      
72         ${XML_SOURCES}
73         ${DIR_WATCH_SOURCE}
74 )
75 if(DBUS_ENABLE_STATS)
76         list(APPEND BUS_SOURCES
77                 ${BUS_DIR}/stats.c
78                 ${BUS_DIR}/stats.h
79         )
80 endif(DBUS_ENABLE_STATS)
81
82 include_directories(
83         ${CMAKE_BINARY_DIR}
84         ${CMAKE_SOURCE_DIR}/..
85         ${XML_INCLUDE_DIR}
86 )
87
88 add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c)
89 target_link_libraries(dbus-daemon ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
90 set_target_properties(dbus-daemon PROPERTIES OUTPUT_NAME ${DBUS_DAEMON_NAME})
91 set_target_properties(dbus-daemon PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
92
93 install_targets(/bin dbus-daemon)
94 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/session.conf DESTINATION etc/dbus-1)
95 install(DIRECTORY DESTINATION etc/dbus-1/session.d)
96 install(DIRECTORY DESTINATION share/dbus-1/services)
97
98 if(NOT WIN32)
99     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/system.conf DESTINATION etc/dbus-1)
100     install(DIRECTORY DESTINATION etc/dbus-1/system.d)
101     install(DIRECTORY DESTINATION share/dbus-1/system-services)
102     install(DIRECTORY DESTINATION var/run/dbus)
103 endif()
104
105 if (DBUS_SERVICE)
106         set (dbus_service_SOURCES 
107                 ${BUS_DIR}/bus-service-win.c
108         # TODO: add additional files
109         #       ${BUS_DIR}/service-main.c
110         #       ${BUS_SOURCES} 
111         )
112
113         add_executable(dbus-service ${dbus_service_SOURCES} )
114         target_link_libraries(dbus-service ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
115         set_target_properties(dbus-service PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
116         install_targets(/bin dbus-service )
117 endif (DBUS_SERVICE)
118
119 if (DBUS_ENABLE_EMBEDDED_TESTS)
120         set(SOURCES ${BUS_SOURCES} ${BUS_DIR}/test-main.c)
121         add_test_executable(test-bus "${SOURCES}"  ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
122         set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
123         if (NOT WIN32)
124                 set(test_bus_system_SOURCES
125                         ${XML_SOURCES}
126                         ${BUS_DIR}/config-parser-common.c
127                         ${BUS_DIR}/config-parser-trivial.c
128                         ${BUS_DIR}/utils.c
129                         ${BUS_DIR}/test-system.c
130                 )
131                 add_test_executable(test-bus-system "${test_bus_system_SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} ${DBUS_BUS_LIBS})
132         endif()
133 endif (DBUS_ENABLE_EMBEDDED_TESTS)
134
135 if(MSVC)
136         project_source_group(${GROUP_CODE} bus_test_SOURCES dummy)
137 endif(MSVC)
138
139 ## mop up the gcov files
140 #clean-local:
141 #       /bin/rm *.bb *.bbg *.da *.gcov || true
142
143 #install-data-hook:
144 #       $(mkinstalldirs) $(DESTDIR)/$(localstatedir)/run/dbus
145 #       $(mkinstalldirs) $(DESTDIR)/$(configdir)/system.d
146 #       $(mkinstalldirs) $(DESTDIR)/$(datadir)/dbus-1/services
147
148 ##install_file(${configdir}/system.d FILE
149
150
151 set(LAUNCH_HELPER_SOURCES ${XML_SOURCES}
152     ${BUS_DIR}/config-parser-common.c
153     ${BUS_DIR}/config-parser-trivial.c
154     ${BUS_DIR}/desktop-file.c
155     ${BUS_DIR}/utils.c
156     ${BUS_DIR}/activation-helper.c
157
158 )
159
160 if(NOT WIN32)
161 # TODO PENDING(kdab) fix build on windows (activation-helper.c)
162    add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c )
163    target_link_libraries(dbus-daemon-launch-helper ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} )
164    
165    add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES}     ${BUS_DIR}/activation-helper-bin.c)
166    set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST")
167    target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} )
168    
169    set (SOURCES ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c)
170    add_test_executable(test-bus-launch-helper "${SOURCES}"  ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
171    set_target_properties(test-bus-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM")
172 endif(NOT WIN32)
173
174 #### Init scripts fun
175 #SCRIPT_IN_FILES=messagebus.in
176 #               rc.messagebus.in
177
178 ## Red Hat start
179 #if DBUS_INIT_SCRIPTS_RED_HAT
180
181 #initddir=$(sysconfdir)/rc.d/init.d
182
183 #initd_SCRIPTS=         
184 #       messagebus
185
186 #endif
187 # ## Red Hat end
188
189 ## Slackware start
190 #if DBUS_INIT_SCRIPTS_SLACKWARE
191
192 #initddir=$(sysconfdir)/rc.d/
193
194 #initd_SCRIPTS=         
195 #       rc.messagebus
196
197 #endif
198 ## Slackware end
199
200 #MAN_IN_FILES=dbus-daemon.1.in
201 #man_MANS = dbus-daemon.1
202
203 #### Extra dist 
204
205 #EXTRA_DIST=$(CONFIG_IN_FILES) $(SCRIPT_IN_FILES) $(man_MANS) $(MAN_IN_FILES)