Tizen 2.4.0 rev3 SDK Public Release
[framework/web/wrt-commons.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 #
16 # @file        CMakeLists.txt
17 # @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
18 # @version     1.0
19 # @brief
20 #
21
22 # Check minimum CMake version
23 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
24
25 # Project name
26 PROJECT(dpl)
27
28 STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
29 ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
30
31 # Comment this to disable control of global settings with environment variable
32 ADD_DEFINITIONS("-DGLOBAL_SETTINGS_CONTROL")
33
34 # Build type
35 IF(NOT CMAKE_BUILD_TYPE)
36     SET(CMAKE_BUILD_TYPE "Release")
37 ENDIF(NOT CMAKE_BUILD_TYPE)
38
39 # Options
40 OPTION(DPL_LOG "DPL logs status" ON)
41 ADD_DEFINITIONS(-DLOG_TAG="WRT_COMMONS")
42 IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
43     MESSAGE(STATUS "Logging enabled for DPL")
44     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
45 ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
46     MESSAGE(STATUS "Logging disabled for DPL")
47 ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
48
49 OPTION(WITH_TESTS "Build tests" OFF)
50 OPTION(WITH_CHILD "Build additional test subdirectory. WITH_TEST must be ON" OFF)
51 OPTION(WEB_PROVIDER_SUPPORT "Support for Web Provider" OFF)
52
53 IF(DEVICE_PROFILE STREQUAL "WEARABLE")
54     MESSAGE(STATUS "Device Profile: WEARABLE")
55     ADD_DEFINITIONS("-DDEVICE_PROFILE_WEARABLE")
56 ELSEIF(DEVICE_PROFILE STREQUAL "MOBILE")
57     MESSAGE(STATUS "Device Profile: MOBILE")
58     ADD_DEFINITIONS("-DDEVICE_PROFILE_MOBILE")
59 ELSEIF(DEVICE_PROFILE STREQUAL "TV")
60     MESSAGE(STATUS "Device Profile: TV")
61     ADD_DEFINITIONS("-DDEVICE_PROFILE_TV")
62     SET(WEB_PROVIDER_SUPPORT OFF)
63 ENDIF()
64
65 INCLUDE(build/Options.cmake)
66
67 # Compiler flags
68 SET(CMAKE_C_FLAGS_PROFILING    "-O2")
69 SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
70 SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
71 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
72 SET(CMAKE_C_FLAGS_RELEASE      "-O2 -g")
73 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g -fvisibility-inlines-hidden")
74 SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
75
76 ADD_DEFINITIONS("-fPIC")                        # If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC. (BJ: our ARM too?)
77
78 # CMake settings
79 MESSAGE(STATUS "========================================")
80 MESSAGE(STATUS "CMAKE_BINARY_DIR:         " ${CMAKE_BINARY_DIR})
81 MESSAGE(STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR})
82 MESSAGE(STATUS "CMAKE_SOURCE_DIR:         " ${CMAKE_SOURCE_DIR})
83 MESSAGE(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
84 MESSAGE(STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR})
85 MESSAGE(STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR})
86 MESSAGE(STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH})
87 MESSAGE(STATUS "LIBRARY_OUTPUT_PATH:     " ${LIBRARY_OUTPUT_PATH})
88 MESSAGE(STATUS "CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH})
89 MESSAGE(STATUS "CMAKE_COMMAND: " ${CMAKE_COMMAND})
90 MESSAGE(STATUS "CMAKE_ROOT: " ${CMAKE_ROOT})
91 MESSAGE(STATUS "CMAKE_CURRENT_LIST_FILE: " ${CMAKE_CURRENT_LIST_FILE})
92 MESSAGE(STATUS "CMAKE_CURRENT_LIST_LINE: " ${CMAKE_CURRENT_LIST_LINE})
93 MESSAGE(STATUS "CMAKE_INCLUDE_PATH: " ${CMAKE_INCLUDE_PATH})
94 MESSAGE(STATUS "CMAKE_LIBRARY_PATH: " ${CMAKE_LIBRARY_PATH})
95 MESSAGE(STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM})
96 MESSAGE(STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME})
97 MESSAGE(STATUS "CMAKE_SYSTEM_VERSION: " ${CMAKE_SYSTEM_VERSION})
98 MESSAGE(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
99 MESSAGE(STATUS "UNIX: " ${UNIX})
100 MESSAGE(STATUS "WIN32: " ${WIN32})
101 MESSAGE(STATUS "APPLE: " ${APPLE})
102 MESSAGE(STATUS "MINGW: " ${MINGW})
103 MESSAGE(STATUS "CYGWIN: " ${CYGWIN})
104 MESSAGE(STATUS "BORLAND: " ${BORLAND})
105 MESSAGE(STATUS "MSVC: " ${MSVC})
106 MESSAGE(STATUS "MSVC_IDE: " ${MSVC_IDE})
107 MESSAGE(STATUS "MSVC60: " ${MSVC60})
108 MESSAGE(STATUS "MSVC70: " ${MSVC70})
109 MESSAGE(STATUS "MSVC71: " ${MSVC71})
110 MESSAGE(STATUS "MSVC80: " ${MSVC80})
111 MESSAGE(STATUS "CMAKE_COMPILER_2005: " ${CMAKE_COMPILER_2005})
112 MESSAGE(STATUS "CMAKE_SKIP_RULE_DEPENDENCY: " ${CMAKE_SKIP_RULE_DEPENDENCY})
113 MESSAGE(STATUS "CMAKE_SKIP_INSTALL_ALL_DEPENDENCY: " ${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY})
114 MESSAGE(STATUS "CMAKE_SKIP_RPATH: " ${CMAKE_SKIP_RPATH})
115 MESSAGE(STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE})
116 MESSAGE(STATUS "CMAKE_SUPPRESS_REGENERATION: " ${CMAKE_SUPPRESS_REGENERATION})
117 MESSAGE(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS})
118 MESSAGE(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
119 MESSAGE(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
120 MESSAGE(STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS})
121 MESSAGE(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER})
122 MESSAGE(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER})
123 MESSAGE(STATUS "CMAKE_COMPILER_IS_GNUCC: " ${CMAKE_COMPILER_IS_GNUCC})
124 MESSAGE(STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX})
125 MESSAGE(STATUS "CMAKE_AR: " ${CMAKE_AR})
126 MESSAGE(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB})
127 MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
128 MESSAGE(STATUS "WITH_CHILD: " ${WITH_CHILD})
129 MESSAGE(STATUS "========================================")
130
131 # Compiler flags
132 ADD_DEFINITIONS("-fvisibility=default")         # mark all exported symbols as visible
133
134 # Warnings mode
135 #ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
136
137 # Warning flags
138 ADD_DEFINITIONS("-Wall")                        # Generate all warnings
139 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
140 ADD_DEFINITIONS("-pedantic")                    # Accept only pedantic code
141 #ADD_DEFINITIONS("-Weffc++")                     # Accept only effective C++ code
142 ADD_DEFINITIONS("-Wwrite-strings")              # Do not accept writing to contant string memory
143 ADD_DEFINITIONS("-Winit-self")                  # Do not accept initializing variable with itself
144 ADD_DEFINITIONS("-Wcast-align")                 # Do not accept misaligning with casting
145 ADD_DEFINITIONS("-Wcast-qual")                  # Do not accept removing qualifiers with casting
146 #ADD_DEFINITIONS("-Wold-style-cast")             # Do not accept old style casting
147 ADD_DEFINITIONS("-Wpointer-arith")              # Warn about void pointer arthimetic
148 ADD_DEFINITIONS("-Wstrict-aliasing")            # Ensure strict aliasing
149 ADD_DEFINITIONS("-Wuninitialized")              # Do not accept uninitialized variables
150 ADD_DEFINITIONS("-Wmissing-declarations")       # Warn about global and non-accesible functions
151 ADD_DEFINITIONS("-Woverloaded-virtual")         # Warn about incidental overiding non-virtual base methods
152 ADD_DEFINITIONS("-Wnon-virtual-dtor")           # Warn about non-virtual destructor
153 ADD_DEFINITIONS("-Wctor-dtor-privacy")          # Warn about useless and non-constructible classes
154 #ADD_DEFINITIONS("-Wlong-long")                  # Do not allow using long long
155 #ADD_DEFINITIONS("-Wunreachable-code")           # Warn about unreachable code
156 ADD_DEFINITIONS("-Wfloat-equal")                # Do not accept comparing floating points with equal operator
157 ADD_DEFINITIONS("-Wabi")                        # Warn about possible ABI problems
158 ADD_DEFINITIONS("-Wswitch-enum")                # Check switch enumeration
159 ADD_DEFINITIONS("-Wformat=2")                   # Check printf formatting
160 ADD_DEFINITIONS("-Wundef")                      # Warn if an undefined identifier is evaluated in an @if directive.
161 ADD_DEFINITIONS("-Wshadow")                     # Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed
162 ADD_DEFINITIONS("-Wconversion")                 # Warn for implicit conversions that may alter a value
163 ADD_DEFINITIONS("-Wlogical-op")                 # Warn about suspicious uses of logical operators in expressions
164 #ADD_DEFINITIONS("-Waggregate-return")           # Warn if any functions that return structures or unions are defined or called.
165 ADD_DEFINITIONS("-Wmissing-field-initializers") # Warn if a structure's initializer has some fields missing.
166 ADD_DEFINITIONS("-Wredundant-decls")            # Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing.
167 #ADD_DEFINITIONS("-Wmissing-include-dirs")       # Warn if a user-supplied include directory does not exist.
168 ADD_DEFINITIONS("-Wswitch-default")             # Warn whenever a switch statement does not have a default case.
169 ADD_DEFINITIONS("-Wsync-nand")                  # Warn when __sync_fetch_and_nand and __sync_nand_and_fetch built-in functions are used. These functions changed semantics in GCC 4.4.
170 ADD_DEFINITIONS("-Wunused")                     # All the above -Wunused options combined.
171 ADD_DEFINITIONS("-Wstrict-overflow=5")          # Also warn about cases where the compiler reduces the magnitude of a constant involved in a comparison.
172 #ADD_DEFINITIONS("-Wunsafe-loop-optimizations")  # Warn if the loop cannot be optimized because the compiler could not assume anything on the bounds of the loop indices. With -funsafe-loop-optimizations warn if the compiler made such assumptions.
173 #ADD_DEFINITIONS("-Wmissing-format-attribute")   # Warn about function pointers which might be candidates for format attributes.
174 #ADD_DEFINITIONS("-Wpadded")                     # Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure.
175 #ADD_DEFINITIONS("-Winline")                     # Warn if a function can not be inlined and it was declared as inline.
176 ADD_DEFINITIONS("-Wdisabled-optimization")      # Warn if a requested optimization pass is disabled.
177 ADD_DEFINITIONS("-std=c++0x")
178 ADD_DEFINITIONS("-Wno-variadic-macros")
179
180 #
181 # Core library files
182 #
183 # Define all core library headers and sources. As detail files
184 # are usually templated and though recompiled in each file, we
185 # have to compile full source for each target.
186 #
187
188 # Set names of binaries being created
189 SET(TARGET_DPL_EFL "lib${PROJECT_NAME}-efl")
190 SET(TARGET_DPL_DBUS_EFL "lib${PROJECT_NAME}-dbus-efl")
191 SET(TARGET_DPL_DB_EFL "lib${PROJECT_NAME}-db-efl")
192 SET(TARGET_DPL_EVENT_EFL "lib${PROJECT_NAME}-event-efl")
193 SET(TARGET_DPL_SOCKET_EFL "lib${PROJECT_NAME}-socket-efl")
194 SET(TARGET_DPL_RPC_EFL "lib${PROJECT_NAME}-rpc-efl")
195 SET(TARGET_DPL_TEST_ENGINE_EFL "lib${PROJECT_NAME}-test-efl")
196 SET(TARGET_DPL_LOG_EFL "lib${PROJECT_NAME}-log-efl")
197 SET(TARGET_WRT_DAO_RW_LIB "dpl-wrt-dao-rw")
198 SET(TARGET_WRT_DAO_RO_LIB "dpl-wrt-dao-ro")
199 SET(TARGET_CUSTOM_HANDLER_DAO_RW_LIB "wrt-commons-custom-handler-dao-rw")
200 SET(TARGET_CUSTOM_HANDLER_DAO_RO_LIB "wrt-commons-custom-handler-dao-ro")
201 SET(TARGET_SECURITY_ORIGIN_DAO_LIB "wrt-commons-security-origin-dao")
202 SET(TARGET_CERTIFICATE_DAO_LIB "wrt-commons-certificate-dao")
203 SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl")
204 SET(TARGET_I18N_DAO_RO_LIB "wrt-commons-i18n-dao-ro")
205 SET(TARGET_WIDGET_INTERFACE_DAO_LIB "wrt-commons-widget-interface-dao")
206 SET(TARGET_WRT_TRACE "wrt-trace")
207
208 MACRO(configure_and_install_pkg PKG_FILE)
209     CONFIGURE_FILE(${PKG_FILE}.in ${PKG_FILE} @ONLY)
210     INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG_FILE} DESTINATION lib/pkgconfig)
211 ENDMACRO(configure_and_install_pkg)
212
213 ADD_SUBDIRECTORY(modules)
214
215 ADD_SUBDIRECTORY(build)
216 ADD_SUBDIRECTORY(etc)
217
218 IF(WITH_TESTS)
219   ADD_SUBDIRECTORY(tests)
220 ENDIF(WITH_TESTS)