Add build Option for multi-user support
[platform/core/appfw/aul-1.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
3
4 PROJECT(aul C)
5 SET(VERSION_MAJOR 0)
6 SET(VERSION "${VERSION_MAJOR}.1.0")
7
8 ### Global setting ###
9
10 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
11 SET(EXEC_PREFIX "\${prefix}")
12
13 # Build type : Release
14 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
15         SET(CMAKE_BUILD_TYPE "Release")
16 ENDIF()
17 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
18
19
20 # Set required packages
21 INCLUDE(FindPkgConfig)
22
23 OPTION(MULTI_USER_SUPPORT "Enable multi-user support" OFF)
24 OPTION(ENABLE_PRIVACY_MANAGER "Enable privacy manager support" ON)
25 IF(ENABLE_PRIVACY_MANAGER)
26     ADD_DEFINITIONS("-DPRIVACY_MANAGER")
27     pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info app2sd privacy-manager-client)
28 ELSE(ENABLE_PRIVACY_MANAGER)
29     pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info app2sd)
30 ENDIF(ENABLE_PRIVACY_MANAGER)
31 IF(MULTI_USER_SUPPORT)
32     ADD_DEFINITIONS("-DMULTI_USER_SUPPORT")
33 ELSE(MULTI_USER_SUPPORT)
34         ADD_DEFINITIONS("-DDAC_ACTIVATE")
35 ENDIF(MULTI_USER_SUPPORT)
36
37 pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker libsmack)
38 PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 gio-2.0 dlog bundle)
39
40 FIND_LIBRARY(LIB_DL dl)
41
42 FOREACH(flag ${libpkgs_CFLAGS})
43         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
44 ENDFOREACH(flag)
45
46 FOREACH(flag ${pkgs_CFLAGS})
47         SET(TEST_CFLAGS "${TEST_CFLAGS} ${flag}")
48 ENDFOREACH(flag)
49
50 # Compiler flags
51 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
52 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/legacy)
53 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/feature)
54 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
55 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
56 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic")
57 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
58 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
59 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
60 SET(CMAKE_C_FLAGS_RELEASE "-O2")
61
62 SET(CMAKE_SKIP_BUILD_RPATH true)
63
64 # Get uname value to set 'TARGET' definition 
65 # TODO: Is this needed?
66 FIND_PROGRAM(UNAME NAMES uname)
67 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
68 IF("${ARCH}" STREQUAL "arm")
69         ADD_DEFINITIONS("-DTARGET")
70         MESSAGE("add -DTARGET")
71 ENDIF("${ARCH}" STREQUAL "arm")
72
73 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
74 ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"")
75
76 # Linker flags
77 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
78
79
80 ### Build ###
81
82 # aul_mods : modules (static library)
83 add_library(aul_mods STATIC
84                 src/app_sock.c
85                 src/simple_util.c
86                 )
87
88 # aul
89 add_library(aul SHARED
90                 src/pkginfo.c
91                 src/launch.c
92                 src/launch_glib.c
93                 src/launch_with_result.c
94                 src/service.c
95                 src/mime.c
96                 src/mida.c
97                 src/miregex.c
98                 src/app_signal.c
99                 src/key.c
100                 src/status.c
101                 )
102 target_link_libraries(aul aul_mods ${libpkgs_LDFLAGS})
103 SET_TARGET_PROPERTIES(aul PROPERTIES SOVERSION ${VERSION_MAJOR})
104 SET_TARGET_PROPERTIES(aul PROPERTIES VERSION ${VERSION})
105
106 # launchpad(old avatar) daemon
107 SET(AVATAR_NAME "launchpad_preloading_preinitializing_daemon")
108 add_executable(${AVATAR_NAME}
109         launchpad_src/launchpad.c
110         launchpad_src/util_x.c
111         )
112
113 MESSAGE("       "${pkgs_LDFLAGS})
114 target_link_libraries(${AVATAR_NAME} aul_mods aul ${pkgs_LDFLAGS} ${LIB_DL})
115 set_target_properties(${AVATAR_NAME}
116                 PROPERTIES SKIP_BUILD_RPATH true
117                 ) # remove rpath option that is automatically generated by cmake.
118
119 add_executable(amd
120                 am_daemon/amd_main.c
121                 am_daemon/amd_key.c
122                 am_daemon/amd_request.c
123                 am_daemon/amd_appinfo.c
124                 am_daemon/amd_cgutil.c
125                 am_daemon/amd_launch.c
126                 am_daemon/amd_status.c
127                 )
128 target_link_libraries(amd aul_mods app-checker-server rua glib-2.0 bundle ail aul utilX ${pkgs_LDFLAGS})
129
130 SET(REL_AGENT daemon-manager-release-agent)
131 ADD_EXECUTABLE(${REL_AGENT} agent/${REL_AGENT}.c)
132 TARGET_LINK_LIBRARIES(${REL_AGENT} ${PKGS_LDFLAGS} aul aul_mods)
133 SET_TARGET_PROPERTIES(${REL_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
134
135 INSTALL(TARGETS ${REL_AGENT} DESTINATION bin)
136
137 SET(LAUNCH_AGENT daemon-manager-launch-agent)
138 ADD_EXECUTABLE(${LAUNCH_AGENT} agent/${LAUNCH_AGENT}.c)
139 TARGET_LINK_LIBRARIES(${LAUNCH_AGENT} ${PKGS_LDFLAGS})
140 SET_TARGET_PROPERTIES(${LAUNCH_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
141
142 INSTALL(TARGETS ${LAUNCH_AGENT} DESTINATION bin)
143
144
145
146 # pkgconfig file
147 CONFIGURE_FILE(aul.pc.in aul.pc @ONLY)
148 CONFIGURE_FILE(legacy/preload_list.txt.in legacy/preload_list.txt @ONLY)
149 CONFIGURE_FILE(feature/preexec_list.txt.in feature/preexec_list.txt @ONLY)
150
151 ### Install ###
152 INSTALL(TARGETS aul DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
153 INSTALL(TARGETS ${AVATAR_NAME} DESTINATION bin)
154 INSTALL(TARGETS amd DESTINATION bin)
155
156 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul.h DESTINATION include/aul)
157 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_service.h DESTINATION include/aul)
158 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/SLP_AUL_PG.h DESTINATION include/aul)
159 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_service.sh DESTINATION bin)
160 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_service_test.sh DESTINATION bin)
161 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_mime.sh DESTINATION bin)
162 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
163
164 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/legacy/preload_list.txt DESTINATION /usr/share/aul )
165 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION /usr/share/aul )
166 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mida_db.sql DESTINATION /usr/share/aul )
167 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION /usr/share/aul )
168 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/service DESTINATION /usr/share/aul )
169
170 # test
171 add_subdirectory(test)
172