Merge "Update license agreement" into devel/tizen_3.0
[platform/core/api/motion.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(motion)
3 INCLUDE(GNUInstallDirs)
4
5 # Target lib (for backward compatibility, the below old naming is used)
6 SET(target "core-context-manager")
7
8 # Source Lists
9 FILE(GLOB_RECURSE SRCS src/*.cpp)
10
11 SET(inc_subdir "context-service")
12 SET(dependency "glib-2.0 dlog capi-base-common capi-system-info sensor")
13
14 # Options
15 INCLUDE(FindPkgConfig)
16 INCLUDE_DIRECTORIES(
17         ${CMAKE_CURRENT_SOURCE_DIR}/include
18         ${CMAKE_CURRENT_SOURCE_DIR}/src/shared
19 )
20
21 ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden)
22 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section")
23
24 # Build
25 pkg_check_modules(pkgs REQUIRED ${dependency})
26
27 FOREACH(flag ${pkgs_CFLAGS})
28    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
29 ENDFOREACH(flag)
30
31 ADD_LIBRARY(${target} SHARED ${SRCS})
32 TARGET_LINK_LIBRARIES(${target} ${pkgs_LDFLAGS})
33 SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
34 SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-LIB\"")
35 SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER})
36 SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER})
37
38 # Install
39 INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
40 INSTALL(
41         DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${inc_subdir}
42         FILES_MATCHING PATTERN "*.h"
43 )
44
45 SET(VERSION ${FULLVER})
46 SET(PC_PREFIX ${CMAKE_INSTALL_PREFIX})
47 SET(PC_NAME ${PROJECT_NAME})
48 SET(PC_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
49 SET(PC_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${inc_subdir}")
50 SET(PC_DESCRIPTION "Tizen Native Motion Recognition API")
51 SET(PC_REQUIRED ${dependency})
52 SET(PC_LDFLAGS -l${target})
53 SET(PC_CFLAGS -I\${includedir}/${inc_subdir})
54
55 CONFIGURE_FILE(
56         ${PROJECT_NAME}.pc.in
57         ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc
58         @ONLY
59 )
60 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)