fixed build on x86_64
[platform/core/api/network-info.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2
3 SET(project_prefix "capi")
4 SET(prefix "/usr")
5 SET(version "0.0.1")
6 SET(maintainer "ByungWoo Lee <bw1212.lee@samsung.com>")
7 SET(description "Telephony Network Information Framework")
8 SET(service "telephony")
9 SET(submodule "network-info")
10 SET(dependents "dlog vconf glib-2.0 capi-base-common")
11 SET(pc_dependents "capi-base-common")
12 SET(deb_dependents "dlog-dev libvconf-dev libglib2.0-dev capi-base-common-dev")
13
14 SET(Services 
15         "application"
16         "base"
17         "content"
18         "location"
19         "media"
20         "messaging"
21         "network"
22         "social"
23         "telephony"
24         "system"
25    )
26
27 #FILE(STRINGS config.cfg configs REGEX "^ *[^#]")
28 FOREACH(lines ${configs})
29 #    MESSAGE(${lines})
30     IF(${lines} MATCHES "([^=]*)=['\"](.*)['\"]")
31         SET(key ${CMAKE_MATCH_1})
32         SET(value ${CMAKE_MATCH_2})
33 #        MESSAGE("${key} -> ${value}")
34         SET(${key} "${value}")
35     ENDIF()
36 ENDFOREACH(lines ${configs})
37
38 LIST(FIND Services ${service} sfind)
39
40 IF( ${sfind} EQUAL -1 )
41     MESSAGE(FATAL_ERROR "Service must be one of ")
42     FOREACH( s IN ${Services} )
43         MESSAGE(FATAL_ERROR "[${s}]")
44     ENDFOREACH( s IN ${Services} )
45 ENDIF( ${sfind} EQUAL -1 )
46
47 SET(fw_name "${project_prefix}-${service}-${submodule}")
48
49 PROJECT(${fw_name})
50
51 SET(CMAKE_INSTALL_PREFIX ${prefix})
52 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
53 SET(VERSION ${version})
54
55 SET(INC_DIR include)
56 INCLUDE_DIRECTORIES(${INC_DIR})
57
58 INCLUDE(FindPkgConfig)
59 pkg_check_modules(${fw_name} REQUIRED ${dependents})
60 FOREACH(flag ${${fw_name}_CFLAGS})
61     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
62 ENDFOREACH(flag)
63
64 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
65 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
66
67 IF("${ARCH}" STREQUAL "arm")
68     ADD_DEFINITIONS("-DTARGET")
69 ENDIF("${ARCH}" STREQUAL "arm")
70
71 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
72 ADD_DEFINITIONS("-DTIZEN_DEBUG")
73
74 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
75
76 aux_source_directory(src SOURCES)
77 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
78
79 TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
80
81 SET_TARGET_PROPERTIES(${fw_name}
82      PROPERTIES
83      VERSION ${FULLVER}
84      SOVERSION ${MAJORVER}
85      CLEAN_DIRECT_OUTPUT 1
86 )
87
88 INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
89 INSTALL(
90         DIRECTORY ${INC_DIR}/ DESTINATION include/${service}
91         FILES_MATCHING
92         PATTERN "*_private.h" EXCLUDE
93         PATTERN "${INC_DIR}/*.h"
94         )
95
96 SET(PC_NAME ${fw_name})
97 SET(PC_REQUIRED ${pc_dependents})
98 SET(PC_LDFLAGS -l${fw_name})
99
100 CONFIGURE_FILE(
101     capi-telephony-network-info.pc.in
102     ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
103     @ONLY
104 )
105 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
106
107 IF(UNIX)
108
109 ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
110 ADD_CUSTOM_COMMAND(
111         DEPENDS clean 
112         COMMENT "distribution clean"
113         COMMAND find
114         ARGS    . 
115         -not -name config.cmake -and \(
116         -name tester.c -or
117         -name Testing -or
118         -name CMakeFiles -or
119         -name cmake.depends -or
120         -name cmake.check_depends -or
121         -name CMakeCache.txt -or
122         -name cmake.check_cache -or
123         -name *.cmake -or
124         -name Makefile -or
125         -name core -or
126         -name core.* -or
127         -name gmon.out -or
128         -name install_manifest.txt -or
129         -name *.pc -or
130         -name *~ \)
131         | grep -v TC | xargs rm -rf
132         TARGET  distclean
133         VERBATIM
134 )
135
136 ENDIF(UNIX)