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