summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 0c4e82d2be873a9d05fd909a3848da3ac4b7d39f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(device-node C)

SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(EXEC_PREFIX "${PREFIX}/bin")
SET(LIBDIR ${LIB_INSTALL_DIR})
SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}")
SET(VERSION 0.1)

SET(INC_DIR include)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/${INC_DIR})

INCLUDE(FindPkgConfig)
pkg_check_modules(rpkgs REQUIRED dlog vconf glib-2.0)

FOREACH(flag ${rpkgs_CFLAGS})
	SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)

SET(SRCS
	src/device-node.c
	src/device-plugin.c)

SET(HEADERS
	include/device-node.h
	include/devman_plugin_intf.h)

INCLUDE(devices/CMakeLists.txt)

SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror -Wl,-zdefs")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")

ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}\"")

ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${TARGET_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS} "-ldl")
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)

ADD_LIBRARY(hwcommon SHARED hw/common.c)
TARGET_LINK_LIBRARIES(hwcommon ${rpkgs_LDFLAGS} "-ldl")
SET_TARGET_PROPERTIES(hwcommon PROPERTIES SOVERSION ${VERSION})
INSTALL(TARGETS hwcommon DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)

CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)

# will be deprecated
CONFIGURE_FILE(devman_plugin.pc.in devman_plugin.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/devman_plugin.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)

FOREACH(hfile ${HEADERS})
	INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
ENDFOREACH(hfile)

INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hw/ DESTINATION include/hw
		FILES_MATCHING
		PATTERN "*.h")

CONFIGURE_FILE(hwcommon.pc.in hwcommon.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hwcommon.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)

IF(BUILD_GTESTS STREQUAL on)
	ADD_SUBDIRECTORY(unittest)
ENDIF()