summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 1710ff5f876043ae2cd4446e26d6728643154b82 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(media-thumbnail C)
SET(VERSION_MAJOR 1)
SET(VERSION "${VERSION_MAJOR}.0.0")

SET(MEDIATHUMB-LIB "media-thumbnail")
SET(MEDIAHASH-LIB "media-hash")
SET(SRCS 
	src/media-thumbnail.c
	src/media-thumb-internal.c
	src/util/media-thumb-debug.c
	src/util/media-thumb-util.c
	src/util/media-thumb-db.c
	src/codec/IfegDecodeAGIF.c
	src/codec/img-codec.c
	src/codec/img-codec-osal.c
	src/codec/img-codec-parser.c
	src/ipc/media-thumb-ipc.c
	)
SET(HASH_SRCS
	md5/md5.c
	md5/media-thumb-hash.c
	)

SET(THUMB-SERVER server/thumb-server.c server/thumb-server-internal.c)
SET(TEST-THUMB test/test-thumb.c)

SET(VENDOR "samsung")
SET(PACKAGE ${PROJECT_NAME})
SET(PKGNAME "com.${VENDOR}.${PACKAGE}")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(BINDIR "${PREFIX}/bin")
SET(DATADIR "${PREFIX}/share")
SET(EXEC_PREFIX "\${prefix}")
SET(LIBDIR "\${prefix}/lib")
SET(INCLUDEDIR "\${prefix}/include")

IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
	SET(CMAKE_BUILD_TYPE "Release")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/codec ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/ipc ${CMAKE_SOURCE_DIR}/server/include ${CMAKE_SOURCE_DIR}/md5)

INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
glib-2.0 gthread-2.0 dlog libmedia-service mm-fileinfo drm-service aul
libexif ecore-evas evas mmutil-imgp mmutil-jpeg heynoti)


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

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC")

FIND_PROGRAM(UNAME NAMES uname)
EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
IF("${ARCH}" STREQUAL "arm")
	ADD_DEFINITIONS("-DTARGET")
	MESSAGE("add -DTARGET")
ENDIF("${ARCH}" STREQUAL "arm")

ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
#ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_")

SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both")
CONFIGURE_FILE(media-thumbnail.pc.in media-thumbnail.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/media-thumbnail.pc DESTINATION lib/pkgconfig)

LINK_DIRECTORIES(lib)

ADD_LIBRARY(${MEDIAHASH-LIB} SHARED ${HASH_SRCS})
SET_TARGET_PROPERTIES(${MEDIAHASH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${MEDIAHASH-LIB} PROPERTIES VERSION ${VERSION})
ADD_LIBRARY(${MEDIATHUMB-LIB} SHARED ${SRCS})
TARGET_LINK_LIBRARIES(${MEDIATHUMB-LIB} ${pkgs_LDFLAGS} ${MEDIAHASH-LIB})
SET_TARGET_PROPERTIES(${MEDIATHUMB-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${MEDIATHUMB-LIB} PROPERTIES VERSION ${VERSION})

INSTALL(TARGETS ${MEDIATHUMB-LIB} LIBRARY DESTINATION lib)
INSTALL(TARGETS ${MEDIAHASH-LIB} LIBRARY DESTINATION lib)

ADD_EXECUTABLE(media-thumbnail-server ${THUMB-SERVER})
TARGET_LINK_LIBRARIES(media-thumbnail-server ${pkgs_LDFLAGS} ${MEDIATHUMB-LIB} )
INSTALL(TARGETS media-thumbnail-server DESTINATION ${BINDIR})

ADD_EXECUTABLE(test-thumb ${TEST-THUMB})
TARGET_LINK_LIBRARIES(test-thumb ${pkgs_LDFLAGS} ${MEDIATHUMB-LIB} )
INSTALL(TARGETS test-thumb DESTINATION ${BINDIR})

INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumbnail.h DESTINATION include/${MEDIATHUMB-LIB})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumbnail-private.h DESTINATION include/${MEDIATHUMB-LIB})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumb-error.h DESTINATION include/${MEDIATHUMB-LIB})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumb-types.h DESTINATION include/${MEDIATHUMB-LIB})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/thumbsvr DESTINATION /etc/init.d)