89d4d51fe08e31352081107e90dca8846ce73137
[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         find_program(PATH_TO_ZIP zip)
43         find_program(PATH_TO_UNZIP unzip)
44         add_definitions(-DUSE_LIBZIP=0 -DPATH_TO_ZIP="${PATH_TO_ZIP}" -DPATH_TO_UNZIP="${PATH_TO_UNZIP}")
45 endif(USE_LIBZIP)
46
47 ###########################################################################
48
49 include_directories(simulation)
50
51 ###########################################################################
52
53 add_compile_options(-Wall -Wno-pointer-sign)
54 add_compile_options(-ffunction-sections -fdata-sections)
55 add_compile_options(-fPIC)
56 add_compile_options(-Wl,--gc-sections)
57
58 set(CMAKE_C_FLAGS_PROFILING    "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE")
59 set(CMAKE_C_FLAGS_DEBUG        "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
60 set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
61 set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
62
63 ###########################################################################
64
65 add_library(wgtpkg
66         wgtpkg-base64.c
67         wgtpkg-certs.c
68         wgtpkg-digsig.c
69         wgtpkg-files.c
70         wgtpkg-install.c
71         wgtpkg-permissions.c
72         wgtpkg-workdir.c
73         wgtpkg-xmlsec.c
74         wgtpkg-zip.c
75         )
76
77 add_library(utils
78         utils-dir.c
79         utils-jbus.c
80         verbose.c
81         )
82
83 add_library(wgt
84         wgt-config.c
85         wgt-info.c
86         wgt.c
87         )
88
89 add_library(secwrp
90         secmgr-wrap.c
91         )
92
93 add_library(afm
94         afm-db.c
95         afm-launch.c
96         afm-run.c
97         )
98
99 add_executable(wgtpkg-sign wgtpkg-sign.c)
100 target_link_libraries(wgtpkg-sign wgtpkg utils)
101
102 add_executable(wgtpkg-pack wgtpkg-pack.c)
103 target_link_libraries(wgtpkg-pack wgtpkg utils)
104
105 add_executable(wgtpkg-info wgtpkg-info.c)
106 target_link_libraries(wgtpkg-info wgtpkg wgt utils)
107
108 add_executable(wgtpkg-installer wgtpkg-installer.c)
109 target_link_libraries(wgtpkg-installer wgtpkg wgt secwrp utils)
110
111 add_executable(afm-user-daemon afm-user-daemon.c)
112 target_link_libraries(afm-user-daemon afm secwrp wgt utils)
113
114 add_executable(afm-system-daemon afm-system-daemon.c)
115 target_link_libraries(afm-system-daemon wgtpkg afm secwrp wgt utils)
116
117 install(TARGETS wgtpkg-sign wgtpkg-pack wgtpkg-info wgtpkg-installer DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
118 install(TARGETS afm-user-daemon DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
119 install(TARGETS afm-system-daemon DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
120