Refactor gdbus interface codes
[platform/core/api/peripheral-io.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 SET(project_prefix "capi")
3 SET(prefix "/usr")
4 SET(libdir ${LIB_INSTALL_DIR})
5 SET(version "0.0.1")
6 SET(service "system")
7 SET(submodule "peripheral-io")
8 SET(fw_name "${project_prefix}-${service}-${submodule}")
9
10 PROJECT(${fw_name})
11
12 SET(dependents "dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-base-common")
13 SET(pc_dependents "capi-base-common")
14
15 SET(CMAKE_INSTALL_PREFIX ${prefix})
16 SET(PREFIX $(CMAKE_INSTALL_PREFIX))
17 SET(VERSION ${version})
18
19 FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
20 EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
21                 " \\
22                 --generate-c-code ${CMAKE_SOURCE_DIR}/src/peripheral_io_gdbus \\
23                 --c-namespace PeripheralIoGdbus \\
24                 --interface-prefix org.tizen.peripheral_io. \\
25                 ${CMAKE_SOURCE_DIR}/src/peripheral_io.xml \\
26                 ")
27
28 SET(INC_DIR include)
29 INCLUDE_DIRECTORIES(${INC_DIR})
30
31 INCLUDE(FindPkgConfig)
32 pkg_check_modules(${fw_name} REQUIRED ${dependents})
33 FOREACH(flag ${${fw_name}_CFLAGS})
34         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
35 ENDFOREACH(flag)
36
37 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
38
39 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror -fPIC")
40 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
41 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
42
43 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=%{_libdir}")
44
45 SET(SOURCES src/peripheral_gpio.c
46                         src/peripheral_i2c.c
47                         src/peripheral_pwm.c
48                         src/peripheral_adc.c
49                         src/peripheral_uart.c
50                         src/peripheral_gdbus_gpio.c
51                         src/peripheral_gdbus_i2c.c
52                         src/peripheral_gdbus_pwm.c
53                         src/peripheral_io_gdbus.c
54                         src/peripheral_spi.c)
55
56 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
57
58 TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
59
60 SET_TARGET_PROPERTIES(${fw_name}
61          PROPERTIES
62          VERSION ${FULLVER}
63          SOVERSION ${MAJORVER}
64          CLEAN_DIRECT_OUTPUT 1
65 )
66
67 INSTALL(TARGETS ${fw_name} DESTINATION ${libdir})
68 INSTALL(
69                 DIRECTORY ${INC_DIR}/ DESTINATION include
70                 FILES_MATCHING
71                 PATTERN "${INC_DIR}/*.h"
72                 )
73
74 SET(PC_NAME ${fw_name})
75 SET(PC_REQUIRED ${pc_dependents})
76 SET(PC_LDFLAGS -l${fw_name})
77
78 CONFIGURE_FILE(
79         ${PROJECT_NAME}.pc.in
80         ${PROJECT_NAME}.pc
81         @ONLY
82 )
83 INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${libdir}/pkgconfig)
84
85 ADD_SUBDIRECTORY(test)