Make DBUS transparency optional (off by default)
[src/app-framework-binder.git] / src / CMakeLists.txt
1 ###########################################################################
2 # Copyright (C) 2015-2018 "IoT.bzh"
3 #
4 # author: José Bollo <jose.bollo@iot.bzh>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ###########################################################################
18
19 if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
20     message(FATAL_ERROR "Require at least gcc-4.9")
21 endif(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
22
23 ADD_DEFINITIONS(-DBINDING_INSTALL_DIR="${binding_install_dir}")
24 # Always add INFER_EXTENSION (more details in afb-hreq.c)
25 ADD_DEFINITIONS(-DINFER_EXTENSION)
26
27 ADD_LIBRARY(afb-lib STATIC
28         afb-api.c
29         afb-api-dyn.c
30         afb-api-so.c
31         afb-api-so-v1.c
32         afb-api-so-v2.c
33         afb-api-so-vdyn.c
34         afb-api-ws.c
35         afb-apiset.c
36         afb-auth.c
37         afb-common.c
38         afb-config.c
39         afb-context.c
40         afb-cred.c
41         afb-debug.c
42         afb-evt.c
43         afb-export.c
44         afb-fdev.c
45         afb-hook.c
46         afb-hreq.c
47         afb-hsrv.c
48         afb-hswitch.c
49         afb-method.c
50         afb-monitor.c
51         afb-msg-json.c
52         afb-proto-ws.c
53         afb-session.c
54         afb-stub-ws.c
55         afb-supervision.c
56         afb-systemd.c
57         afb-trace.c
58         afb-websock.c
59         afb-ws-client.c
60         afb-ws-json1.c
61         afb-ws.c
62         afb-wsj1.c
63         afb-xreq.c
64         fdev.c
65         fdev-epoll.c
66         fdev-systemd.c
67         jobs.c
68         locale-root.c
69         process-name.c
70         sig-monitor.c
71         subpath.c
72         verbose.c
73         websock.c
74         wrap-json.c
75 )
76
77 IF(INCLUDE_DBUS_TRANSPARENCY)
78         ADD_DEFINITIONS(-DWITH_DBUS_TRANSPARENCY)
79         TARGET_SOURCES(afb-lib PUBLIC afb-api-dbus.c)
80 ENDIF()
81
82 ###########################################
83 # build and install afb-daemon
84 ###########################################
85 ADD_EXECUTABLE(afb-daemon main.c)
86 TARGET_LINK_LIBRARIES(afb-daemon
87         afb-lib
88         ${link_libraries}
89 )
90 INSTALL(TARGETS afb-daemon
91         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
92
93 ###########################################
94 # build and install afb-daemon
95 ###########################################
96 IF(INCLUDE_SUPERVISOR)
97         ADD_EXECUTABLE(afs-supervisor afs-main.c afs-supervisor.c afs-discover.c afs-config.c)
98         TARGET_LINK_LIBRARIES(afs-supervisor
99                 afb-lib
100                 ${link_libraries}
101         )
102         INSTALL(TARGETS afs-supervisor
103                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
104 ENDIF()
105
106 ###########################################
107 # build and install libafbwsc
108 ###########################################
109 ADD_LIBRARY(afbwsc SHARED afb-ws.c afb-ws-client.c afb-wsj1.c websock.c afb-proto-ws.c jobs-fake.c fdev.c fdev-systemd.c)
110 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
111         VERSION ${LIBAFBWSC_VERSION}
112         SOVERSION ${LIBAFBWSC_SOVERSION})
113 TARGET_LINK_LIBRARIES(afbwsc
114         ${libsystemd_LDFLAGS}
115         ${json-c_LDFLAGS}
116         -lpthread
117         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
118         -Wl,--as-needed
119         -Wl,--gc-sections
120 )
121 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
122 INSTALL(FILES afb-wsj1.h afb-ws-client.h afb-proto-ws.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
123
124 ###########################################
125 # build and install afb-client-demo
126 ###########################################
127 ADD_EXECUTABLE(afb-client-demo afb-client-demo.c)
128 TARGET_LINK_LIBRARIES(afb-client-demo
129         afbwsc
130         ${link_libraries}
131         ${libsystemd_LDFLAGS}
132 )
133 INSTALL(TARGETS afb-client-demo
134         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
135