1 # Copyright (c) 2014 Samsung Electronics Co., Ltd
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 cmake_minimum_required (VERSION 2.8.3)
19 option(USE_FUNCTION_FS "Use FunctionFS" NO)
20 option(BUILD_UNIT_TESTS "Build unit tests" NO)
23 ############################# cmake packages ##################################
25 INCLUDE(FindPkgConfig)
27 ############################# compiler flags ##################################
37 src/file_sync_service.c
38 src/usb_linux_client.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
51 src/commandline_sdbd.c
52 src/usb_linux_client.c
53 src/usb_funcfs_client.c
54 src/default_plugin_auth.c
55 src/default_plugin_basic.c
56 src/default_plugin_main.c
57 src/default_plugin_event.c
58 src/default_plugin_appcmd.c
61 src/transport_security.c
64 include(FindPkgConfig)
66 pkg_check_modules(pkgs REQUIRED
76 FOREACH(flag ${pkgs_CFLAGS})
77 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
80 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
82 INCLUDE_DIRECTORIES(src)
84 ADD_DEFINITIONS("-O2 -g -Wall -Wno-unused-parameter -fPIE")
85 ADD_DEFINITIONS("-DSDB_HOST=0")
86 ADD_DEFINITIONS("-D_XOPEN_SOURCE")
87 ADD_DEFINITIONS("-D_GNU_SOURCE")
88 ADD_DEFINITIONS("-DHAVE_FORKEXEC")
89 ADD_DEFINITIONS("-D_DROP_PRIVILEGE")
90 ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
91 ADD_DEFINITIONS("-DSUPPORT_ENCRYPT")
94 ADD_DEFINITIONS("-DANDROID_GADGET=1")
97 IF(TARGET_ARCH STREQUAL x86)
98 ADD_DEFINITIONS("-DTARGET_ARCH_X86")
100 ADD_DEFINITIONS("-DTARGET_ARCH_ARM")
103 IF(WEARABLE_PROFILE STREQUAL on)
104 ADD_DEFINITIONS("-D_WEARABLE")
107 find_package(Threads REQUIRED)
109 ADD_EXECUTABLE(sdbd ${SDBD_SRCS})
110 TARGET_LINK_LIBRARIES(sdbd -pie -lsmack -lresolv -ldl ${CMAKE_THREAD_LIBS_INIT} ${pkgs_LDFLAGS})
114 PROPERTY COMPILE_DEFINITIONS
122 APPEND PROPERTY COMPILE_DEFINITIONS
131 APPEND PROPERTY COMPILE_DEFINITIONS
136 install(TARGETS sdbd DESTINATION /usr/sbin)
137 install(FILES script/sdbd DESTINATION /etc/init.d)
140 # Optionally build unit tests binary -- could be helpful during further development
143 add_subdirectory(test)