59897317e9c995466126a9f0efb9523028d5afe9
[framework/connectivity/bluetooth-frwk.git] / lib / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(bluetooth-api C)
3
4 SET(SRCS bluetooth-api-common.c marshal.c bluetooth-gap-api.c bluetooth-sdp-api.c bluetooth-rfcomm-api.c bluetooth-network-api.c bluetooth-hdp-api.c obex-agent.c bluetooth-opc-api.c 
5 bluetooth-obex-server-api.c bluetooth-hid-api.c)
6 SET(HEADERS bluetooth-api.h bluetooth-hid-api.h)
7
8 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
9 SET(EXEC_PREFIX "\${prefix}")
10 SET(LIBDIR "\${prefix}/lib")
11 SET(INCLUDEDIR "\${prefix}/include")
12 SET(VERSION_MAJOR 1)
13 SET(VERSION ${VERSION_MAJOR}.0.0)
14
15 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
16
17 INCLUDE(FindPkgConfig)
18 pkg_check_modules(packages REQUIRED dlog dbus-glib-1 gobject-2.0 gmodule-2.0 vconf 
19 libxml-2.0 syspopup-caller)
20
21 FOREACH(flag ${packages_CFLAGS})
22         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
23 ENDFOREACH(flag)
24
25 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
26 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g ")
27
28 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
29
30 FIND_PROGRAM(UNAME NAMES uname)
31 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
32 IF("${ARCH}" STREQUAL "arm")
33         ADD_DEFINITIONS("-DTARGET")
34         MESSAGE("add -DTARGET")
35 ENDIF("${ARCH}" STREQUAL "arm")
36
37 FIND_PROGRAM(MARSHALTOOL NAMES glib-genmarshal)
38 EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --header > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.h")
39 EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --body > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.c")
40
41 FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
42 EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=obex_agent ${CMAKE_CURRENT_SOURCE_DIR}/obex-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/obex-agent-glue.h")
43
44 #SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
45
46 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
47 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
48 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
49 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${packages_LDFLAGS})
50
51 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
52
53 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
54 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
55
56 FOREACH(hfile ${HEADERS})
57         INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-api)
58 ENDFOREACH(hfile)
59