Tizen 2.0 Release
[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
29 include_directories(
30   ${dpl_INCLUDE_DIRS}
31   ${CMAKE_CURRENT_SOURCE_DIR}/src/
32   ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/API
33   ${CMAKE_CURRENT_SOURCE_DIR}/src/Commons
34   ${CMAKE_CURRENT_SOURCE_DIR}/src/CommonsJavaScript
35   ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-loading
36   ${CMAKE_CURRENT_SOURCE_DIR}/src/js-overlay
37   ${CMAKE_CURRENT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner)
38
39 ##############################################################################
40 # Build type
41 IF(NOT CMAKE_BUILD_TYPE)
42     SET(CMAKE_BUILD_TYPE "Release")
43 ENDIF(NOT CMAKE_BUILD_TYPE)
44
45 # Compiler flags
46 SET(CMAKE_C_FLAGS_PROFILING    "-O2")
47 SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
48 SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
49 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
50 SET(CMAKE_C_FLAGS_RELEASE      "-O2 -g")
51 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
52 SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
53 ####
54
55 OPTION(DPL_LOG "DPL logs status" ON)
56 OPTION(WITH_TESTS "Build tests" OFF)
57
58 IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
59     MESSAGE(STATUS "Logging enabled for DPL")
60     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
61 ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
62     MESSAGE(STATUS "Logging disabled for DPL")
63 ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
64
65 MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
66
67 ADD_DEFINITIONS("-fPIC")
68 ADD_DEFINITIONS("-fvisibility=default")         # mark all exported symbols as visible
69 ADD_DEFINITIONS("-fPIC")                        # If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding
70 ADD_DEFINITIONS("-DEXPORT_API=")
71 ADD_DEFINITIONS("-Wall")
72 #ADD_DEFINITIONS("-Werror")
73 ADD_DEFINITIONS("-Wextra")
74 ADD_DEFINITIONS("-Wno-deprecated")
75 #ADD_DEFINITIONS("-DDEVPKG")
76
77 ##############################################################################
78 # CMake flags
79 IF (DEVPKG)
80     SET(DEVPKG "ON")
81 ENDIF(DEVPKG)
82
83 ################################################################################
84 # Miscellaneous variables
85
86 set(CONFIG_FILE_NAME "config.cmake")
87 set(LIBS_COMMONS ${dpl_LDFLAGS} )
88
89 set(DESTINATION_LIB_PREFIX lib)
90 set(DESTINATION_HEADER_PREFIX include/${PROJECT_NAME})
91
92 set(DESTINATION_HEADERS_NON_JS ${DESTINATION_HEADER_PREFIX}/Commons)
93 set(DESTINATION_HEADERS_JS ${DESTINATION_HEADER_PREFIX}/CommonsJavaScript)
94 set(DESTINATION_HEADERS_JS_OVERLAY ${DESTINATION_HEADER_PREFIX}/js-overlay)
95 set(DESTINATION_HEADERS_WRT_POPUP_RUNNER ${DESTINATION_HEADER_PREFIX}/popup-runner)
96
97 ################################################################################
98 # Target platform
99
100 if (NOT DEFINED PLATFORM)
101   set(PLATFORM "tizen")
102 endif ()
103
104 ################################################################################
105 # Schema of plugin's configuration file
106
107 set(COMMON_CONFIG_DTD ${CMAKE_CURRENT_SOURCE_DIR}/config.dtd)
108 set(COMMON_CONFIG_DTD_DST /usr/etc/wrt-plugins)
109 INSTALL(FILES ${COMMON_CONFIG_DTD} DESTINATION ${COMMON_CONFIG_DTD_DST})
110
111 ################################################################################
112 # Macros used for including plugins from AL.
113
114
115 function(add_subdir NAME)
116   message(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}")
117   add_subdirectory(${NAME})
118 endfunction()
119
120 ################################################################################
121 # Subdirectories
122
123 add_subdirectory(src)
124
125 IF(WITH_TESTS)
126   add_subdirectory(tests)
127 ENDIF(WITH_TESTS)
128
129 ################################################################################
130 # PKGCONFIG
131
132 set(PKGCONFIG_DIR ${PROJECT_SOURCE_DIR}/pkgconfigs)
133
134 macro(configure_and_install_pkg PKG_FILE)
135     CONFIGURE_FILE(${PKGCONFIG_DIR}/${PKG_FILE}.in
136                ${PKGCONFIG_DIR}/${PKG_FILE} @ONLY)
137     INSTALL(FILES ${PKGCONFIG_DIR}/${PKG_FILE} DESTINATION lib/pkgconfig)
138 endmacro(configure_and_install_pkg)
139
140 configure_and_install_pkg(wrt-plugins-commons-javascript.pc)
141 configure_and_install_pkg(wrt-plugins-commons.pc)
142 configure_and_install_pkg(wrt-plugins-filesystem.pc)
143 configure_and_install_pkg(wrt-plugins-widget-interface-dao.pc)
144 configure_and_install_pkg(wrt-plugins-widgetdb.pc)
145 configure_and_install_pkg(wrt-plugins-plugin-manager.pc)
146 configure_and_install_pkg(wrt-plugin-loading.pc)
147 configure_and_install_pkg(wrt-plugin-js-overlay.pc)
148 configure_and_install_pkg(wrt-popup-runner.pc)
149 configure_and_install_pkg(wrt-popup-ace-runner.pc)
150 configure_and_install_pkg(wrt-popup-wrt-runner.pc)
151 configure_and_install_pkg(wrt-plugins-api-support.pc)
152
153 ################################################################################
154 # Cache
155
156 set(PLATFORM "${PLATFORM}" CACHE STRING "Target platform" FORCE)
157 set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_NAME}" CACHE
158     STRING "CMake configuration file name." FORCE)
159
160
161 ################################################################################
162 # Summary
163
164 message(STATUS "PLATFORM = ${PLATFORM}")