1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(media-thumbnail C)
4 SET(VERSION "${VERSION_MAJOR}.0.0")
6 SET(MEDIATHUMB-LIB "media-thumbnail")
7 SET(MEDIAHASH-LIB "media-hash")
10 src/util/media-thumb-util.c
11 src/ipc/media-thumb-ipc.c
15 md5/media-thumb-hash.c
19 SET(PACKAGE ${PROJECT_NAME})
20 SET(PKGNAME "com.${VENDOR}.${PACKAGE}")
21 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
22 SET(BINDIR "${PREFIX}/bin")
23 SET(LOCALBINDIR "${PREFIX}/local/bin")
24 SET(DATADIR "${PREFIX}/share")
25 SET(EXEC_PREFIX "\${prefix}")
26 SET(LIBDIR "\${prefix}/lib")
27 SET(INCLUDEDIR "\${prefix}/include")
29 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
30 SET(CMAKE_BUILD_TYPE "Release")
31 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
32 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
34 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/ipc ${CMAKE_SOURCE_DIR}/server/include ${CMAKE_SOURCE_DIR}/md5)
36 INCLUDE(FindPkgConfig)
37 pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 mm-fileinfo aul libmedia-utils libtzplatform-config mmutil-common mmutil-magick)
39 FOREACH(flag ${pkgs_CFLAGS})
40 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
43 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -Wno-deprecated-declarations -D_FORTIFY_SOURCE=2")
44 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
45 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC")
47 FIND_PROGRAM(UNAME NAMES uname)
48 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
49 IF("${ARCH}" STREQUAL "arm")
50 ADD_DEFINITIONS("-DTARGET")
51 MESSAGE("add -DTARGET")
52 ENDIF("${ARCH}" STREQUAL "arm")
54 ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
55 ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
56 ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
57 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
58 ADD_DEFINITIONS("-D_GNU_SOURCE")
60 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both")
61 CONFIGURE_FILE(media-thumbnail.pc.in media-thumbnail.pc @ONLY)
62 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/media-thumbnail.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
64 LINK_DIRECTORIES(${LIB_INSTALL_DIR})
66 ADD_LIBRARY(${MEDIAHASH-LIB} SHARED ${HASH_SRCS})
67 SET_TARGET_PROPERTIES(${MEDIAHASH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
68 SET_TARGET_PROPERTIES(${MEDIAHASH-LIB} PROPERTIES VERSION ${VERSION})
69 ADD_LIBRARY(${MEDIATHUMB-LIB} SHARED ${SRCS})
70 TARGET_LINK_LIBRARIES(${MEDIATHUMB-LIB} ${pkgs_LDFLAGS} ${MEDIAHASH-LIB})
71 SET_TARGET_PROPERTIES(${MEDIATHUMB-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
72 SET_TARGET_PROPERTIES(${MEDIATHUMB-LIB} PROPERTIES VERSION ${VERSION})
74 INSTALL(TARGETS ${MEDIATHUMB-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
75 INSTALL(TARGETS ${MEDIAHASH-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
77 ADD_SUBDIRECTORY(server)
79 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumbnail.h DESTINATION include/${MEDIATHUMB-LIB})
81 ADD_SUBDIRECTORY(unittest)