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