add data encryption feature
[sdk/target/sdbd.git] / CMakeLists.txt
1 # Copyright (c) 2014 Samsung Electronics Co., Ltd
2 #
3 # Licensed under the Apache License, Version 2.0 (the License);
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an AS IS BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15
16 cmake_minimum_required (VERSION 2.8.3)
17 project (sdbd)
18
19 option(USE_FUNCTION_FS "Use FunctionFS" NO)
20 option(BUILD_UNIT_TESTS "Build unit tests" NO)
21
22
23 ############################# cmake packages ##################################
24
25 INCLUDE(FindPkgConfig)
26
27 ############################# compiler flags ##################################
28
29 SET(SDBD_SRCS
30         src/sdb.c
31         src/fdevent.c
32         src/transport.c
33         src/transport_local.c
34         src/transport_usb.c
35         src/sockets.c
36         src/services.c
37         src/file_sync_service.c
38         src/usb_linux_client.c
39         src/utils.c
40         src/socket_inaddr_any_server.c
41         src/socket_local_client.c
42         src/socket_local_server.c
43         src/socket_loopback_client.c
44         src/socket_loopback_server.c
45         src/socket_network_client.c
46         src/properties.c
47         src/sdktools.c
48         src/strutils.c
49         src/init.c
50         src/fileutils.c
51         src/commandline_sdbd.c
52         src/usb_linux_client.c
53         src/usb_funcfs_client.c
54         src/transport_security.c
55 )
56
57 include(FindPkgConfig)
58
59 pkg_check_modules(pkgs REQUIRED
60     libtzplatform-config
61     capi-system-info
62     vconf
63     glib-2.0
64     dbus-1
65     dbus-glib-1
66         dlog
67  )
68  
69 FOREACH(flag ${pkgs_CFLAGS})
70         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
71 ENDFOREACH(flag)
72
73 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
74
75 INCLUDE_DIRECTORIES(src)
76
77 ADD_DEFINITIONS("-O2 -g -Wall -Wno-unused-parameter -fPIE")
78 ADD_DEFINITIONS("-DSDB_HOST=0")
79 ADD_DEFINITIONS("-D_XOPEN_SOURCE")
80 ADD_DEFINITIONS("-D_GNU_SOURCE")
81 ADD_DEFINITIONS("-DHAVE_FORKEXEC")
82 ADD_DEFINITIONS("-D_DROP_PRIVILEGE")
83 ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
84 ADD_DEFINITIONS("-DSUPPORT_ENCRYPT")
85
86 IF (_ARM_TARGET)
87     ADD_DEFINITIONS("-DANDROID_GADGET=1")
88 ENDIF (_ARM_TARGET)
89
90 IF(TARGET_ARCH STREQUAL x86)
91     ADD_DEFINITIONS("-DTARGET_ARCH_X86")
92 ELSE()
93     ADD_DEFINITIONS("-DTARGET_ARCH_ARM")
94 ENDIF()
95
96 IF(WEARABLE_PROFILE STREQUAL on)
97     ADD_DEFINITIONS("-D_WEARABLE")
98 ENDIF()
99
100 find_package(Threads REQUIRED)
101
102 ADD_EXECUTABLE(sdbd ${SDBD_SRCS})
103 TARGET_LINK_LIBRARIES(sdbd -pie -lsmack -lresolv -ldl ${CMAKE_THREAD_LIBS_INIT} ${pkgs_LDFLAGS})
104
105 set_property(
106         TARGET sdbd
107         PROPERTY COMPILE_DEFINITIONS
108         SDB_HOST=0
109         _DROP_PRIVILEGE
110         _FILE_OFFSET_BITS=64
111 )
112
113 set_property(
114         TARGET sdbd
115         APPEND PROPERTY COMPILE_DEFINITIONS
116         _XOPEN_SOURCE
117         _GNU_SOURCE
118         HAVE_FORKEXEC
119 )
120
121 if(USE_FUNCTION_FS)
122         set_property(
123                 TARGET sdbd
124                 APPEND PROPERTY COMPILE_DEFINITIONS
125                 USB_FUNCFS
126         )
127 endif()
128
129 install(TARGETS sdbd DESTINATION /usr/sbin)
130 install(FILES script/sdbd DESTINATION /etc/init.d)
131
132
133 # Optionally build unit tests binary -- could be helpful during further development
134 if(BUILD_UNIT_TESTS)
135         enable_testing()
136         add_subdirectory(test)
137 endif()