Aarch64: Replace macro __x86_64__ with generic macro __LP64__
[platform/framework/web/wrt-plugins-common.git] / CMakeLists.txt
1 # Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License");
4 #    you may not use this file except in compliance with the License.
5 #    You may obtain a copy of the License at
6 #
7 #        http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS,
11 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #    See the License for the specific language governing permissions and
13 #    limitations under the License.
14 #
15 cmake_minimum_required(VERSION 2.6)
16
17 SET(CMAKE_PROJECT_NAME wrt-plugins-common)
18 set(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
19 project(${CMAKE_PROJECT_NAME})
20 STRING(REGEX MATCH "([^.]*)" CMAKE_PROJECT_API_VERSION "${CMAKE_PROJECT_VERSION}")
21
22 ################################################################################
23 # Required platform modules
24
25 include(FindPkgConfig)
26
27 pkg_search_module(dpl REQUIRED dpl-efl>=0.2.21)
28 pkg_search_module(wrt-commons-custom-handler-dao-ro REQUIRED wrt-commons-custom-handler-dao-ro)
29
30 include_directories(
31   ${dpl_INCLUDE_DIRS}
32   ${CMAKE_CURRENT_SOURCE_DIR}/src/
33   ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/API
34   ${CMAKE_CURRENT_SOURCE_DIR}/src/Commons
35   ${CMAKE_CURRENT_SOURCE_DIR}/src/CommonsJavaScript
36   ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-loading
37   ${CMAKE_CURRENT_SOURCE_DIR}/src/js-overlay
38   ${CMAKE_CURRENT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner
39   ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins_ipc_message
40   ${CMAKE_CURRENT_SOURCE_DIR}/src/dispatch-event)
41
42 ##############################################################################
43 # Build type
44 IF(NOT CMAKE_BUILD_TYPE)
45     SET(CMAKE_BUILD_TYPE "Release")
46 ENDIF(NOT CMAKE_BUILD_TYPE)
47
48 # Compiler flags
49 SET(CMAKE_C_FLAGS_PROFILING    "-O2")
50 SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
51 SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
52 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
53 SET(CMAKE_C_FLAGS_RELEASE      "-O2 -g")
54 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
55 SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
56 ####
57
58 OPTION(DPL_LOG "DPL logs status" ON)
59 OPTION(WITH_TESTS "Build tests" OFF)
60 OPTION(X11_SUPPORT "Enable X11" ON)
61 IF(X11_SUPPORT)
62     ADD_DEFINITIONS("-DX11")
63 ENDIF(X11_SUPPORT)
64
65 IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
66     MESSAGE(STATUS "Logging enabled for DPL")
67     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
68 ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
69     MESSAGE(STATUS "Logging disabled for DPL")
70 ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
71
72 MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
73 MESSAGE( "wrt-commons-custom-handler-dao-ro_CFLAGS_OTHER :  ${wrt-commons-custom-handler-dao-ro_CFLAGS_OTHER}")
74 ADD_DEFINITIONS("${wrt-commons-custom-handler-dao-ro_CFLAGS_OTHER}")
75 ADD_DEFINITIONS("-fPIC")
76 ADD_DEFINITIONS("-fvisibility=default")         # mark all exported symbols as visible
77 ADD_DEFINITIONS("-fPIC")                        # If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding
78 ADD_DEFINITIONS("-DEXPORT_API=")
79 ADD_DEFINITIONS("-Wall")
80 #ADD_DEFINITIONS("-Werror")
81 ADD_DEFINITIONS("-Wextra")
82 ADD_DEFINITIONS("-Wno-deprecated")
83 #ADD_DEFINITIONS("-DDEVPKG")
84 # GCC 4.7 changes the scheme of name lookup. Guide: http://gcc.gnu.org/gcc-4.7/porting_to.html
85 ADD_DEFINITIONS("-fpermissive")
86
87 ADD_DEFINITIONS("-DLIBDIR_PREFIX=\"${LIB_INSTALL_DIR}\"")
88
89 ##############################################################################
90 # CMake flags
91 IF (DEVPKG)
92     SET(DEVPKG "ON")
93 ENDIF(DEVPKG)
94
95 ################################################################################
96 # Miscellaneous variables
97
98 set(CONFIG_FILE_NAME "config.cmake")
99 set(LIBS_COMMONS ${dpl_LDFLAGS} )
100
101 set(DESTINATION_LIB_PREFIX ${LIB_INSTALL_DIR})
102 set(DESTINATION_HEADER_PREFIX include/${PROJECT_NAME})
103
104 set(DESTINATION_HEADERS_NON_JS ${DESTINATION_HEADER_PREFIX}/Commons)
105 set(DESTINATION_HEADERS_JS ${DESTINATION_HEADER_PREFIX}/CommonsJavaScript)
106 set(DESTINATION_HEADERS_JS_OVERLAY ${DESTINATION_HEADER_PREFIX}/js-overlay)
107 set(DESTINATION_HEADERS_WRT_POPUP_RUNNER ${DESTINATION_HEADER_PREFIX}/popup-runner)
108
109 ################################################################################
110 # Target platform
111
112 if (NOT DEFINED PLATFORM)
113   set(PLATFORM "tizen")
114 endif ()
115
116 ################################################################################
117 # Schema of plugin's configuration file
118
119 set(COMMON_CONFIG_DTD ${CMAKE_CURRENT_SOURCE_DIR}/config.dtd)
120 set(COMMON_CONFIG_DTD_DST ${TZ_SYS_WRT_PLUGINS_CONF})
121 INSTALL(FILES ${COMMON_CONFIG_DTD} DESTINATION ${COMMON_CONFIG_DTD_DST})
122
123 ################################################################################
124 # Macros used for including plugins from AL.
125
126
127 function(add_subdir NAME)
128   message(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}")
129   add_subdirectory(${NAME})
130 endfunction()
131
132 ################################################################################
133 # Subdirectories
134
135 add_subdirectory(src)
136
137 IF(WITH_TESTS)
138   add_subdirectory(tests)
139 ENDIF(WITH_TESTS)
140
141 ################################################################################
142 # PKGCONFIG
143
144 set(PKGCONFIG_DIR ${PROJECT_SOURCE_DIR}/pkgconfigs)
145
146 macro(configure_and_install_pkg PKG_FILE)
147     CONFIGURE_FILE(${PKGCONFIG_DIR}/${PKG_FILE}.in
148                ${PKGCONFIG_DIR}/${PKG_FILE} @ONLY)
149     INSTALL(FILES ${PKGCONFIG_DIR}/${PKG_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
150 endmacro(configure_and_install_pkg)
151
152 configure_and_install_pkg(wrt-plugins-commons-javascript.pc)
153 configure_and_install_pkg(wrt-plugins-commons.pc)
154 configure_and_install_pkg(wrt-plugins-filesystem.pc)
155 configure_and_install_pkg(wrt-plugins-widget-interface.pc)
156 configure_and_install_pkg(wrt-plugins-widgetdb.pc)
157 configure_and_install_pkg(wrt-plugins-plugin-manager.pc)
158 configure_and_install_pkg(wrt-plugin-loading.pc)
159 configure_and_install_pkg(wrt-plugin-js-overlay.pc)
160 configure_and_install_pkg(wrt-popup-runner.pc)
161 configure_and_install_pkg(wrt-popup-ace-runner.pc)
162 configure_and_install_pkg(wrt-popup-wrt-runner.pc)
163 configure_and_install_pkg(wrt-plugins-api-support.pc)
164 configure_and_install_pkg(wrt-plugins-ipc-message.pc)
165 configure_and_install_pkg(wrt-dispatch-event.pc)
166
167 ################################################################################
168 # ld configuration file
169
170 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${PACKAGE_NAME}.conf.in
171                ${PROJECT_SOURCE_DIR}/${PACKAGE_NAME}.conf @ONLY)
172 INSTALL(FILES ${PROJECT_SOURCE_DIR}/${PACKAGE_NAME}.conf DESTINATION /etc/ld.so.conf.d/)
173
174
175 ################################################################################
176 # Cache
177
178 set(PLATFORM "${PLATFORM}" CACHE STRING "Target platform" FORCE)
179 set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_NAME}" CACHE
180     STRING "CMake configuration file name." FORCE)
181
182 ################################################################################
183 # SMACK rule
184
185 INSTALL(FILES ${CMAKE_SOURCE_DIR}/wrt-popup-ace-runtime.rule DESTINATION /etc/smack/accesses2.d)
186 INSTALL(FILES ${CMAKE_SOURCE_DIR}/wrt-popup-wrt-runtime.rule DESTINATION /etc/smack/accesses2.d)
187 # temp for smack branch
188 INSTALL(FILES ${CMAKE_SOURCE_DIR}/accesses.d/wrt-popup-ace-runtime.rule DESTINATION ${TZ_SYS_ETC}/smack/accesses.d)
189 INSTALL(FILES ${CMAKE_SOURCE_DIR}/accesses.d/wrt-popup-wrt-runtime.rule DESTINATION ${TZ_SYS_ETC}/smack/accesses.d)
190
191 ################################################################################
192 # Summary
193
194 message(STATUS "PLATFORM = ${PLATFORM}")