Fix build for native package
[src/app-framework-binder.git] / src / CMakeLists.txt
1 ###########################################################################
2 # Copyright 2015, 2016, 2017 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 (NOT DEFINED ALLOW_NO_BINDER)
20     if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
21         message(FATAL_ERROR "Require at least gcc-4.9")
22     endif(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
23 endif(ALLOW_NO_BINDER)
24
25 INCLUDE(FindPkgConfig)
26
27 ADD_SUBDIRECTORY(genskel)
28 ADD_SUBDIRECTORY(tests)
29
30 ADD_DEFINITIONS(-DBINDING_INSTALL_DIR="${binding_install_dir}")
31 # Always add INFER_EXTENSION (more details in afb-hreq.c)
32 ADD_DEFINITIONS(-DINFER_EXTENSION)
33
34 ADD_LIBRARY(afb-lib STATIC
35         afb-api.c
36         afb-api-dbus.c
37         afb-api-dyn.c
38         afb-api-so.c
39         afb-api-so-v1.c
40         afb-api-so-v2.c
41         afb-api-so-vdyn.c
42         afb-api-ws.c
43         afb-apiset.c
44         afb-auth.c
45         afb-common.c
46         afb-config.c
47         afb-context.c
48         afb-cred.c
49         afb-debug.c
50         afb-evt.c
51         afb-export.c
52         afb-hook.c
53         afb-hreq.c
54         afb-hsrv.c
55         afb-hswitch.c
56         afb-method.c
57         afb-monitor.c
58         afb-msg-json.c
59         afb-proto-ws.c
60         afb-session.c
61         afb-stub-ws.c
62         afb-trace.c
63         afb-websock.c
64         afb-ws-client.c
65         afb-ws-json1.c
66         afb-ws.c
67         afb-wsj1.c
68         afb-xreq.c
69         jobs.c
70         locale-root.c
71         process-name.c
72         sd-fds.c
73         sig-monitor.c
74         subpath.c
75         verbose.c
76         websock.c
77         wrap-json.c
78 )
79
80 ###########################################
81 # build and install afb-daemon
82 ###########################################
83 ADD_EXECUTABLE(afb-daemon main.c)
84 TARGET_LINK_LIBRARIES(afb-daemon
85         afb-lib
86         ${link_libraries}
87 )
88 INSTALL(TARGETS afb-daemon
89         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
90
91 ###########################################
92 # build and install libafbwsc
93 ###########################################
94 ADD_LIBRARY(afbwsc SHARED afb-ws.c afb-ws-client.c afb-wsj1.c websock.c afb-proto-ws.c)
95 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
96         VERSION ${LIBAFBWSC_VERSION}
97         SOVERSION ${LIBAFBWSC_SOVERSION})
98 TARGET_LINK_LIBRARIES(afbwsc
99         ${libsystemd_LDFLAGS}
100         ${json-c_LDFLAGS}
101         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
102         -Wl,--as-needed
103         -Wl,--gc-sections
104 )
105 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
106 INSTALL(FILES afb-wsj1.h afb-ws-client.h afb-proto-ws.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
107
108 ###########################################
109 # build and install afb-client-demo
110 ###########################################
111 ADD_EXECUTABLE(afb-client-demo afb-client-demo.c)
112 TARGET_LINK_LIBRARIES(afb-client-demo
113         afbwsc
114         ${link_libraries}
115         ${libsystemd_LDFLAGS}
116 )
117 INSTALL(TARGETS afb-client-demo
118         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
119
120