Add app-defined loader
[platform/core/appfw/launchpad.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 SET (this_target_pool launchpad_pool)
3 SET (this_target_loader launchpad_loader)
4 SET (this_target_lib launchpad)
5 SET (this_target_hydra launchpad_hydra)
6
7 INCLUDE(FindPkgConfig)
8 PKG_CHECK_MODULES(${this_target_pool} REQUIRED
9         dlog
10         libsystemd
11         security-manager
12         tanchor
13         bundle
14         gio-2.0
15         ttrace
16         vconf
17         libtzplatform-config
18         libcap
19         dbus-1
20         iniparser
21         )
22
23 FOREACH(flag ${${this_target_pool}_CFLAGS})
24         SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${flag}")
25 ENDFOREACH(flag)
26
27 PKG_CHECK_MODULES(${this_target_loader} REQUIRED
28         dlog
29         ecore
30         elementary
31         security-manager
32         libtzplatform-config
33         tanchor
34         bundle
35         aul
36         vconf
37         buxton2
38         libsystemd
39         gio-2.0
40         dbus-1
41         libcap
42         )
43
44 FOREACH(flag ${${this_target_loader}_CFLAGS})
45         SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${flag}")
46 ENDFOREACH(flag)
47
48 PKG_CHECK_MODULES(${this_target_lib} REQUIRED
49         dlog
50         bundle
51         aul
52         security-manager
53         libtzplatform-config
54         tanchor
55         dbus-1
56         libcap
57         )
58
59 FOREACH(flag ${${this_target_lib}_CFLAGS})
60         SET(EXTRA_CFLAGS_lib "${EXTRA_CFLAGS_lib} ${flag}")
61 ENDFOREACH(flag)
62
63 PKG_CHECK_MODULES(${this_target_hydra} REQUIRED
64         dlog
65         libsystemd)
66
67 FOREACH(flag ${${this_target_hydra}_CFLAGS})
68         SET(EXTRA_CFLAGS_hydra "${EXTRA_CFLAGS_hydra} ${flag}")
69 ENDFOREACH(flag)
70
71 SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -Wl,-zdefs" )
72 SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -fvisibility=hidden")
73 SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -fdata-sections -ffunction-sections -Wl,--gc-sections")
74 SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -D_FILE_OFFSET_BITS=64")
75 SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -Werror")
76
77 IF(_TIZEN_FEATURE_PRELINK)
78 MESSAGE(STATUS "[__PRELINK__] Enable")
79 SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${EXTRA_CFLAGS_common}")
80 SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${EXTRA_CFLAGS_common}")
81 ELSE(_TIZEN_FEATURE_PRELINK)
82 MESSAGE(STATUS "[__PRELINK__] Disable")
83 SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${EXTRA_CFLAGS_common} -fPIE")
84 SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${EXTRA_CFLAGS_common} -fPIE")
85 ENDIF(_TIZEN_FEATURE_PRELINK)
86
87 SET(EXTRA_CFLAGS_lib "${EXTRA_CFLAGS_lib} ${EXTRA_CFLAGS_common}")
88 SET(EXTRA_CFLAGS_hydra "${EXTRA_CFLAGS_hydra} ${EXTRA_CFLAGS_common}")
89
90 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
91 SET(CMAKE_C_FLAGS_RELEASE "-O2")
92 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
93
94 ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"")
95 IF(_TIZEN_FEATURE_PRIORITY_CHANGE)
96         ADD_DEFINITIONS("-DTIZEN_FEATURE_PRIORITY_CHANGE")
97 ENDIF(_TIZEN_FEATURE_PRIORITY_CHANGE)
98 IF(_TIZEN_FEATURE_LOADER_PRIORITY)
99         ADD_DEFINITIONS("-DTIZEN_FEATURE_LOADER_PRIORITY")
100 ENDIF(_TIZEN_FEATURE_LOADER_PRIORITY)
101 IF(_TIZEN_FEATURE_SET_PERSONALITY_32)
102         ADD_DEFINITIONS("-DTIZEN_FEATURE_SET_PERSONALITY_32")
103 ENDIF(_TIZEN_FEATURE_SET_PERSONALITY_32)
104
105 ADD_DEFINITIONS("-DLAUNCHPAD_LOG")
106 ADD_DEFINITIONS("-DPRELOAD_ACTIVATE")
107 ADD_DEFINITIONS("-DPREEXEC_ACTIVATE")
108 #ADD_DEFINITIONS("-DPERF_ACTIVATE")
109
110 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
111
112 # launchpad-loader
113 SET(LAUNCHPAD_LOADER "launchpad-loader")
114 SET(${LAUNCHPAD_LOADER}_SOURCE_FILES
115         src/launchpad_loader.c
116         src/launchpad_common.c
117         src/launchpad_lib.c
118         )
119 ADD_EXECUTABLE(${LAUNCHPAD_LOADER} ${${LAUNCHPAD_LOADER}_SOURCE_FILES})
120
121 # To support 2.x applications which use their own shared libraries.
122 # Since we cannot set LD_LIBRARY_PATH directly by security issue, we make the
123 # dynamic linker looks in the CWD forcely.
124 TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} "-ldl -Wl,-rpath,: -Wl,--disable-new-dtags")
125
126 IF(_TIZEN_FEATURE_PRELINK)
127 TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} ${${this_target_loader}_LDFLAGS})
128 ELSE(_TIZEN_FEATURE_PRELINK)
129 TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} ${${this_target_loader}_LDFLAGS} "-pie")
130 ENDIF(_TIZEN_FEATURE_PRELINK)
131
132 SET_TARGET_PROPERTIES(${LAUNCHPAD_LOADER} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_loader})
133 SET_TARGET_PROPERTIES(${LAUNCHPAD_LOADER}
134         PROPERTIES SKIP_BUILD_RPATH TRUE
135         ) # remove rpath option that is automatically generated by cmake.
136 INSTALL(TARGETS ${LAUNCHPAD_LOADER} DESTINATION bin)
137
138 # launchpad-process-pool
139 SET(LAUNCHPAD_PROCESS_POOL "launchpad-process-pool")
140 SET(${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES
141         src/launchpad.c
142         src/launchpad_common.c
143         src/loader_info.c
144         src/launcher_info.c
145         src/debugger_info.c
146         src/launchpad_debug.c
147         src/launchpad_signal.c
148         src/launchpad_config.c
149         src/launchpad_io_channel.c
150         src/launchpad_inotify.c
151         )
152 ADD_EXECUTABLE(${LAUNCHPAD_PROCESS_POOL} ${${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES})
153
154 IF(_TIZEN_FEATURE_PRELINK)
155 TARGET_LINK_LIBRARIES(${LAUNCHPAD_PROCESS_POOL} ${${this_target_pool}_LDFLAGS} "-lm")
156 ELSE(_TIZEN_FEATURE_PRELINK)
157 TARGET_LINK_LIBRARIES(${LAUNCHPAD_PROCESS_POOL} ${${this_target_pool}_LDFLAGS} "-pie -lm")
158 ENDIF(_TIZEN_FEATURE_PRELINK)
159 SET_TARGET_PROPERTIES(${LAUNCHPAD_PROCESS_POOL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_pool})
160 SET_TARGET_PROPERTIES(${LAUNCHPAD_PROCESS_POOL}
161         PROPERTIES SKIP_BUILD_RPATH TRUE
162         ) # remove rpath option that is automatically generated by cmake.
163
164 CONFIGURE_FILE(packaging/default.debugger.in packaging/default.debugger @ONLY)
165 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/default.debugger DESTINATION share/aul)
166 INSTALL(TARGETS ${LAUNCHPAD_PROCESS_POOL} DESTINATION bin)
167
168 CONFIGURE_FILE(packaging/default.loader.in packaging/default.loader @ONLY)
169 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/default.loader DESTINATION share/aul)
170
171 CONFIGURE_FILE(conf/launchpad.conf.in conf/launchpad.conf @ONLY)
172 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/launchpad.conf DESTINATION share/aul)
173
174 # liblaunchpad
175 SET(LAUNCHPAD_LIB "launchpad")
176 ADD_LIBRARY(${LAUNCHPAD_LIB} SHARED
177                 src/launchpad_lib.c
178                 src/launchpad_common.c
179                 )
180 SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES SOVERSION ${MAJORVER})
181 SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES VERSION ${VERSION})
182 SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_lib})
183 TARGET_LINK_LIBRARIES(${LAUNCHPAD_LIB} ${${this_target_lib}_LDFLAGS} "-ldl")
184
185 INSTALL(TARGETS ${LAUNCHPAD_LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
186 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/launchpad.h DESTINATION include/launchpad)
187 CONFIGURE_FILE(launchpad.pc.in launchpad.pc @ONLY)
188 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/launchpad.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
189 CONFIGURE_FILE(launchpad.pc.in liblaunchpad.pc @ONLY)
190 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblaunchpad.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
191
192 # liblaunchpad_hydra
193 SET(LAUNCHPAD_HYDRA "launchpad-hydra")
194 ADD_LIBRARY(${LAUNCHPAD_HYDRA} SHARED
195         src/launchpad_hydra.c
196         )
197 SET_TARGET_PROPERTIES(${LAUNCHPAD_HYDRA} PROPERTIES SOVERSION ${MAJORVER})
198 SET_TARGET_PROPERTIES(${LAUNCHPAD_HYDRA} PROPERTIES VERSION ${VERSION})
199 SET_TARGET_PROPERTIES(${LAUNCHPAD_HYDRA} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_hydra})
200 TARGET_LINK_LIBRARIES(${LAUNCHPAD_HYDRA} ${${this_target_hydra}_LDFLAGS} "-ldl")
201
202 INSTALL(TARGETS ${LAUNCHPAD_HYDRA} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
203 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/launchpad_hydra.h DESTINATION include/launchpad)
204
205 CONFIGURE_FILE(liblaunchpad-hydra.pc.in liblaunchpad-hydra.pc @ONLY)
206 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblaunchpad-hydra.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
207
208 # parser
209 ADD_SUBDIRECTORY(parser)