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