Improves naming of session's module
[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_DEFINITIONS(-DBINDING_INSTALL_DIR="${binding_install_dir}")
26
27 CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
28 CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
29 IF(HAVE_MAGIC_H)
30   IF(HAVE_LIBMAGIC_SO)
31     SET(HAVE_LIBMAGIC "1")
32   ENDIF(HAVE_LIBMAGIC_SO)
33 ENDIF(HAVE_MAGIC_H)
34
35 IF(NOT HAVE_LIBMAGIC)
36   MESSAGE(FATAL_ERROR "\"magic.h\" or \"libmagic.so\" missing.
37     Please install the \"file-devel\" or \"libmagic-dev\" package !")
38 ENDIF(NOT HAVE_LIBMAGIC)
39
40 PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
41 PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd>=0.9.48)
42 PKG_CHECK_MODULES(openssl REQUIRED openssl)
43 PKG_CHECK_MODULES(uuid REQUIRED uuid)
44
45 INCLUDE_DIRECTORIES(
46         ${include_dirs}
47         ${libsystemd_INCLUDE_DIRS}
48         ${libmicrohttpd_INCLUDE_DIRS}
49         ${uuid_INCLUDE_DIRS}
50         ${openssl_INCLUDE_DIRS}
51 )
52
53 ADD_LIBRARY(afb-lib STATIC
54         afb-api-dbus.c
55         afb-api-so.c
56         afb-api-ws.c
57         afb-apis.c
58         afb-common.c
59         afb-context.c
60         afb-evt.c
61         afb-hook.c
62         afb-hreq.c
63         afb-hsrv.c
64         afb-hswitch.c
65         afb-method.c
66         afb-msg-json.c
67         afb-session.c
68         afb-sig-handler.c
69         afb-svc.c
70         afb-subcall.c
71         afb-thread.c
72         afb-websock.c
73         afb-ws-client.c
74         afb-ws-json1.c
75         afb-ws.c
76         afb-wsj1.c
77         locale-root.c
78         verbose.c
79         websock.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         ${libsystemd_LIBRARIES}
90         ${libmicrohttpd_LIBRARIES}
91         ${uuid_LIBRARIES}
92         ${openssl_LIBRARIES}
93         -lmagic
94         -ldl
95         -lrt
96 )
97 INSTALL(TARGETS afb-daemon
98         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
99
100 ###########################################
101 # build and install libafbwsc
102 ###########################################
103 ADD_LIBRARY(afbwsc SHARED afb-ws.c afb-ws-client.c afb-wsj1.c websock.c)
104 SET_TARGET_PROPERTIES(afbwsc PROPERTIES
105         VERSION ${LIBAFBWSC_VERSION}
106         SOVERSION ${LIBAFBWSC_SOVERSION})
107 TARGET_LINK_LIBRARIES(afbwsc
108         ${libsystemd_LIBRARIES}
109         -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-afbwsc.map
110         -Wl,--as-needed
111         -Wl,--gc-sections
112 )
113 INSTALL(TARGETS afbwsc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
114 INSTALL(FILES afb-wsj1.h afb-ws-client.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/afb)
115
116 ###########################################
117 # build and install afb-client-demo
118 ###########################################
119 ADD_EXECUTABLE(afb-client-demo afb-client-demo.c)
120 TARGET_LINK_LIBRARIES(afb-client-demo
121         afbwsc
122         ${link_libraries}
123         ${libsystemd_LIBRARIES}
124 )
125 INSTALL(TARGETS afb-client-demo
126         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
127
128