Tizen 2.1 base
[platform/core/appfw/xdgmime.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
3
4 PROJECT(xdgmime C)
5 SET(VERSION_MAJOR 1)
6 SET(VERSION "${VERSION_MAJOR}.1.0")
7
8 ### Global setting ###
9
10 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
11 SET(EXEC_PREFIX "\${prefix}")
12 SET(LIBDIR "\${prefix}/lib")
13 SET(INCLUDEDIR "\${prefix}/include")
14
15 # Build type : Release
16 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
17         SET(CMAKE_BUILD_TYPE "Release")
18 ENDIF()
19 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
20
21
22 # Set required packages
23 INCLUDE(FindPkgConfig)
24
25 #pkg_check_modules(libpkgs REQUIRED )
26 #FOREACH(flag ${libpkgs_CFLAGS})
27 #       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
28 #ENDFOREACH(flag)
29
30 # Compiler flags
31 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
32 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
33 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
34 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Wmissing-prototypes -Wno-sign-compare -g -DHAVE_MMAP")
35 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
36 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
37 SET(CMAKE_C_FLAGS_RELEASE "-O2")
38
39 SET(CMAKE_SKIP_BUILD_RPATH true)
40
41 # Get uname value to set 'TARGET' definition 
42 # TODO: Is this needed?
43 FIND_PROGRAM(UNAME NAMES uname)
44 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
45 IF("${ARCH}" STREQUAL "arm")
46         ADD_DEFINITIONS("-DTARGET")
47         MESSAGE("add -DTARGET")
48 ENDIF("${ARCH}" STREQUAL "arm")
49
50 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
51
52 # Linker flags
53 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
54
55 ### Build ###
56
57 # xdgmime
58 add_library(xdgmime SHARED
59         xdgmime/src/xdgmime.c
60         xdgmime/src/xdgmimeglob.c
61         xdgmime/src/xdgmimeint.c
62         xdgmime/src/xdgmimemagic.c
63         xdgmime/src/xdgmimealias.c
64         xdgmime/src/xdgmimeparent.c
65         xdgmime/src/xdgmimecache.c
66         xdgmime/src/xdgmimeicon.c
67         xdgmime/src/xdgmimeglobs2.c
68         )
69 target_link_libraries(xdgmime ${libpkgs_LDFLAGS})
70 SET_TARGET_PROPERTIES(xdgmime PROPERTIES SOVERSION ${VERSION_MAJOR})
71 SET_TARGET_PROPERTIES(xdgmime PROPERTIES VERSION ${VERSION})
72
73 # pkgconfig file
74 CONFIGURE_FILE(xdgmime.pc.in xdgmime.pc @ONLY)
75
76 ### Install ###
77 INSTALL(TARGETS xdgmime DESTINATION lib COMPONENT RuntimeLibraries)
78
79 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/xdgmime/src/xdgmime.h DESTINATION include)
80 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/xdgmime.pc DESTINATION lib/pkgconfig)
81
82 # test
83 add_subdirectory(test)
84