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