Build test-bus-system with cmake on non win32 platforms.
[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}/bus.c                                        
41         ${BUS_DIR}/bus.h                                        
42         ${BUS_DIR}/config-parser.c                              
43         ${BUS_DIR}/config-parser.h
44         ${BUS_DIR}/config-parser-common.c
45         ${BUS_DIR}/config-parser-common.h
46 #    ${BUS_DIR}/config-parser-trivial.c
47         ${BUS_DIR}/connection.c
48         ${BUS_DIR}/connection.h                         
49         ${BUS_DIR}/desktop-file.c                               
50         ${BUS_DIR}/desktop-file.h                               
51         ${BUS_DIR}/dir-watch.h                          
52         ${BUS_DIR}/dispatch.c                           
53         ${BUS_DIR}/dispatch.h                           
54         ${BUS_DIR}/driver.c                             
55         ${BUS_DIR}/driver.h                             
56         ${BUS_DIR}/expirelist.c                         
57         ${BUS_DIR}/expirelist.h                         
58         ${BUS_DIR}/policy.c                             
59         ${BUS_DIR}/policy.h                             
60         ${BUS_DIR}/selinux.h                            
61         ${BUS_DIR}/selinux.c                            
62         ${BUS_DIR}/services.c                           
63         ${BUS_DIR}/services.h                           
64         ${BUS_DIR}/signals.c                            
65         ${BUS_DIR}/signals.h                            
66         ${BUS_DIR}/test.c                                       
67         ${BUS_DIR}/test.h                                       
68         ${BUS_DIR}/utils.c                                      
69         ${BUS_DIR}/utils.h                                      
70         ${XML_SOURCES}
71         ${DIR_WATCH_SOURCE}
72 )
73 if(DBUS_ENABLE_STATS)
74         list(APPEND BUS_SOURCES
75                 ${BUS_DIR}/stats.c
76                 ${BUS_DIR}/stats.h
77         )
78 endif(DBUS_ENABLE_STATS)
79
80 include_directories(
81         ${CMAKE_BINARY_DIR}
82         ${CMAKE_SOURCE_DIR}/..
83         ${XML_INCLUDE_DIR}
84 )
85
86 add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c)
87 target_link_libraries(dbus-daemon ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
88 set_target_properties(dbus-daemon PROPERTIES OUTPUT_NAME ${DBUS_DAEMON_NAME})
89 set_target_properties(dbus-daemon PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
90
91 install_targets(/bin dbus-daemon)
92 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/session.conf DESTINATION etc/dbus-1)
93 install(DIRECTORY DESTINATION etc/dbus-1/session.d)
94 install(DIRECTORY DESTINATION share/dbus-1/services)
95
96 if(NOT WIN32)
97     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/system.conf DESTINATION etc/dbus-1)
98     install(DIRECTORY DESTINATION etc/dbus-1/system.d)
99     install(DIRECTORY DESTINATION share/dbus-1/system-services)
100     install(DIRECTORY DESTINATION var/run/dbus)
101 endif()
102
103 if (DBUS_SERVICE)
104         set (dbus_service_SOURCES 
105                 ${BUS_DIR}/bus-service-win.c
106         # TODO: add additional files
107         #       ${BUS_DIR}/service-main.c
108         #       ${BUS_SOURCES} 
109         )
110
111         add_executable(dbus-service ${dbus_service_SOURCES} )
112         target_link_libraries(dbus-service ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
113         set_target_properties(dbus-service PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
114         install_targets(/bin dbus-service )
115 endif (DBUS_SERVICE)
116
117 if (DBUS_ENABLE_EMBEDDED_TESTS)
118         set(SOURCES ${BUS_SOURCES} ${BUS_DIR}/test-main.c)
119         add_test_executable(test-bus "${SOURCES}"  ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
120         set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
121         if (NOT DBUS_WIN32)
122                 set(test_bus_system_SOURCES
123                         ${XML_SOURCES}
124                         ${BUS_DIR}/config-parser-common.c
125                         ${BUS_DIR}/config-parser-trivial.c
126                         ${BUS_DIR}/utils.c
127                         ${BUS_DIR}/test-system.c
128                 )
129                 add_test_executable(test-bus-system "${test_bus_system_SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} ${DBUS_BUS_LIBS})
130         endif()
131 endif (DBUS_ENABLE_EMBEDDED_TESTS)
132
133 if(MSVC)
134         project_source_group(${GROUP_CODE} bus_test_SOURCES dummy)
135 endif(MSVC)
136
137 ## mop up the gcov files
138 #clean-local:
139 #       /bin/rm *.bb *.bbg *.da *.gcov || true
140
141 #install-data-hook:
142 #       $(mkinstalldirs) $(DESTDIR)/$(localstatedir)/run/dbus
143 #       $(mkinstalldirs) $(DESTDIR)/$(configdir)/system.d
144 #       $(mkinstalldirs) $(DESTDIR)/$(datadir)/dbus-1/services
145
146 ##install_file(${configdir}/system.d FILE
147
148
149 set(LAUNCH_HELPER_SOURCES ${XML_SOURCES}
150     ${BUS_DIR}/config-parser-common.c
151     ${BUS_DIR}/config-parser-trivial.c
152     ${BUS_DIR}/desktop-file.c
153     ${BUS_DIR}/utils.c
154     ${BUS_DIR}/activation-helper.c
155
156 )
157
158 if(NOT WIN32)
159 # TODO PENDING(kdab) fix build on windows (activation-helper.c)
160    add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c )
161    target_link_libraries(dbus-daemon-launch-helper ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} )
162    
163    add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES}     ${BUS_DIR}/activation-helper-bin.c)
164    set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST")
165    target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} )
166    
167    set (SOURCES ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c)
168    add_test_executable(test-bus-launch-helper "${SOURCES}"  ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
169    set_target_properties(test-bus-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM")
170 endif(NOT WIN32)
171
172 #### Init scripts fun
173 #SCRIPT_IN_FILES=messagebus.in
174 #               rc.messagebus.in
175
176 ## Red Hat start
177 #if DBUS_INIT_SCRIPTS_RED_HAT
178
179 #initddir=$(sysconfdir)/rc.d/init.d
180
181 #initd_SCRIPTS=         
182 #       messagebus
183
184 #endif
185 # ## Red Hat end
186
187 ## Slackware start
188 #if DBUS_INIT_SCRIPTS_SLACKWARE
189
190 #initddir=$(sysconfdir)/rc.d/
191
192 #initd_SCRIPTS=         
193 #       rc.messagebus
194
195 #endif
196 ## Slackware end
197
198 #MAN_IN_FILES=dbus-daemon.1.in
199 #man_MANS = dbus-daemon.1
200
201 #### Extra dist 
202
203 #EXTRA_DIST=$(CONFIG_IN_FILES) $(SCRIPT_IN_FILES) $(man_MANS) $(MAN_IN_FILES)