363cdaebf92d1b3d9368de471855fb847e6c7f9f
[apps/agl-service-homescreen.git] / src / CMakeLists.txt
1 #
2 # Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 cmake_minimum_required(VERSION 2.8)
18
19 set(TARGETS_HSBINDER homescreen-service)
20
21 INCLUDE(FindThreads)
22 FIND_PACKAGE(Threads)
23
24 pkg_check_modules(hs_binding_depends afb-daemon glib-2.0 gio-2.0 gio-unix-2.0 json-c)
25 set(binding_hs_sources
26   homescreen.c
27   hs-helper.c)
28
29 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
30 include_directories(${PROJECT_SOURCE_DIR}/include)
31 add_library(${TARGETS_HSBINDER} MODULE ${binding_hs_sources})
32
33 target_compile_options(${TARGETS_HSBINDER} PRIVATE ${hs_binding_depends_CFLAGS})
34 if(DEFINED DEBUGMODE)
35  target_compile_options(${TARGETS_HSBINDER} PRIVATE -g -O0)
36 else(DEFINED DEBUGMODE)
37  target_compile_options(${TARGETS_HSBINDER} PRIVATE -g -O2)
38 endif(DEFINED DEBUGMODE)
39
40 target_include_directories(${TARGETS_HSBINDER} PRIVATE ${hs_binding_depends_INCLUDE_DIRS})
41 target_link_libraries(${TARGETS_HSBINDER} ${CMAKE_THREAD_LIBS_INIT} ${link_libraries} ${hs_binding_depends_LIBRARIES})
42
43 # Binder exposes a unique public entry point
44
45 set_target_properties(${TARGETS_HSBINDER} PROPERTIES
46     PREFIX ""
47     LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.map"
48     )
49
50 # installation directory
51 #INSTALL(TARGETS ${TARGETS_HSBINDER}
52 #    LIBRARY DESTINATION ${binding_install_dir})
53
54 if(NOT EXISTS ${PROJECT_BINARY_DIR}/package)
55     add_custom_command(TARGET ${TARGETS_HSBINDER} POST_BUILD
56         COMMAND cp -rf ${PROJECT_SOURCE_DIR}/package ${PROJECT_BINARY_DIR}
57     )
58 endif()
59
60 add_custom_command(TARGET ${TARGETS_HSBINDER} POST_BUILD
61     COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib
62     COMMAND cp -rf ${PROJECT_BINARY_DIR}/src/${TARGETS_HSBINDER}.so ${PROJECT_BINARY_DIR}/package/root/lib
63 )
64
65 add_custom_target(package DEPENDS ${PROJECT_BINARY_DIR}/package/root
66     COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/${TARGETS_HSBINDER}-2017.wgt ${PROJECT_BINARY_DIR}/package/root
67 )