8971edb6453c5b78214c9ebe05057bbf3945ae8b
[src/app-framework-main.git] / src / CMakeLists.txt
1 ###########################################################################
2 # Copyright 2015 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 cmake_minimum_required(VERSION 2.8)
20
21 include(FindPkgConfig)
22
23 pkg_check_modules(EXTRAS REQUIRED
24         libxml-2.0
25         openssl
26         xmlsec1 xmlsec1-openssl
27         json-c
28         dbus-1
29         )
30
31 add_compile_options(${EXTRAS_CFLAGS})
32 include_directories(${EXTRAS_INCLUDE_DIRS})
33 link_libraries(${EXTRAS_LIBRARIES})
34
35 if(USE_LIBZIP)
36         pkg_check_modules(LIBZIP REQUIRED libzip>=0.11)
37         add_compile_options(${LIBZIP_CFLAGS})
38         include_directories(${LIBZIP_INCLUDE_DIRS})
39         link_libraries(${LIBZIP_LIBRARIES})
40         add_definitions(-DUSE_LIBZIP=1)
41 else(USE_LIBZIP)
42         add_definitions(-DUSE_LIBZIP=0)
43 endif(USE_LIBZIP)
44
45 ###########################################################################
46
47 if(USE_SIMULATION)
48         include_directories(simulation)
49 else(USE_SIMULATION)
50         pkg_check_modules(SECMGR REQUIRED security-manager)
51         add_compile_options(${SECMGR_CFLAGS})
52         include_directories(${SECMGR_INCLUDE_DIRS})
53         link_libraries(${SECMGR_LIBRARIES})
54 endif(USE_SIMULATION)
55
56 ###########################################################################
57
58 add_compile_options(-Wall -Wextra -Wconversion)
59 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
60 add_compile_options(-Werror=maybe-uninitialized)
61 add_compile_options(-Werror=implicit-function-declaration)
62 add_compile_options(-Wno-pointer-sign) # for XmlChar handling
63 add_compile_options(-ffunction-sections -fdata-sections)
64 add_compile_options(-Wl,--gc-sections)
65 add_compile_options(-fPIC)
66
67 set(CMAKE_C_FLAGS_PROFILING    "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE")
68 set(CMAKE_C_FLAGS_DEBUG        "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
69 set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
70 set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
71
72 ###########################################################################
73
74 add_library(wgtpkg
75         wgtpkg-base64.c
76         wgtpkg-certs.c
77         wgtpkg-digsig.c
78         wgtpkg-files.c
79         wgtpkg-install.c
80         wgtpkg-permissions.c
81         wgtpkg-uninstall.c
82         wgtpkg-workdir.c
83         wgtpkg-xmlsec.c
84         wgtpkg-zip.c
85         )
86
87 add_library(utils
88         utils-dir.c
89         utils-jbus.c
90         utils-json.c
91         verbose.c
92         )
93
94 add_library(wgt
95         wgt-config.c
96         wgt-info.c
97         wgt.c
98         )
99
100 add_library(secwrp
101         secmgr-wrap.c
102         )
103
104 add_library(afm
105         afm-db.c
106         afm-launch.c
107         afm-launch-mode.c
108         afm-run.c
109         )
110
111 add_executable(wgtpkg-sign wgtpkg-sign.c)
112 target_link_libraries(wgtpkg-sign wgtpkg utils)
113
114 add_executable(wgtpkg-pack wgtpkg-pack.c)
115 target_link_libraries(wgtpkg-pack wgtpkg utils)
116
117 add_executable(wgtpkg-info wgtpkg-info.c)
118 target_link_libraries(wgtpkg-info wgtpkg wgt utils)
119
120 add_executable(wgtpkg-installer wgtpkg-installer.c)
121 target_link_libraries(wgtpkg-installer wgtpkg wgt secwrp utils)
122
123 add_executable(afm-user-daemon afm-user-daemon.c)
124 target_link_libraries(afm-user-daemon afm secwrp wgt utils)
125
126 add_executable(afm-system-daemon afm-system-daemon.c)
127 target_link_libraries(afm-system-daemon wgtpkg afm secwrp wgt utils)
128
129 install(TARGETS wgtpkg-sign wgtpkg-pack wgtpkg-info wgtpkg-installer DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
130 install(TARGETS afm-user-daemon DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
131 install(TARGETS afm-system-daemon DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
132