tizen 2.3 release
[framework/web/wearable/wrt-security.git] / commons / 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(wrt-security-commons)
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" OFF)
41 IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
42     MESSAGE(STATUS "Logging enabled for DPL")
43     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
44 ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
45     MESSAGE(STATUS "Logging disabled for DPL")
46 ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
47
48 OPTION(WITH_TESTS "Build tests" OFF)
49 OPTION(WITH_CHILD "Build additional test subdirectory. WITH_TEST must be ON" OFF)
50
51 # Compiler flags
52 SET(CMAKE_C_FLAGS_PROFILING    "-O2")
53 SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
54 SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
55 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
56 SET(CMAKE_C_FLAGS_RELEASE      "-O2 -g")
57 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g -fvisibility-inlines-hidden")
58 SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
59
60 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?)
61
62 # Compiler flags
63 ADD_DEFINITIONS("-fvisibility=default")         # mark all exported symbols as visible
64
65 # Warnings mode
66 #ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
67
68 # Warning flags
69 ADD_DEFINITIONS("-Wall")                        # Generate all warnings
70 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
71 ADD_DEFINITIONS("-pedantic")                    # Accept only pedantic code
72 #ADD_DEFINITIONS("-Weffc++")                     # Accept only effective C++ code
73 ADD_DEFINITIONS("-Wwrite-strings")              # Do not accept writing to contant string memory
74 ADD_DEFINITIONS("-Winit-self")                  # Do not accept initializing variable with itself
75 ADD_DEFINITIONS("-Wcast-align")                 # Do not accept misaligning with casting
76 ADD_DEFINITIONS("-Wcast-qual")                  # Do not accept removing qualifiers with casting
77 #ADD_DEFINITIONS("-Wold-style-cast")             # Do not accept old style casting
78 ADD_DEFINITIONS("-Wpointer-arith")              # Warn about void pointer arthimetic
79 ADD_DEFINITIONS("-Wstrict-aliasing")            # Ensure strict aliasing
80 ADD_DEFINITIONS("-Wuninitialized")              # Do not accept uninitialized variables
81 ADD_DEFINITIONS("-Wmissing-declarations")       # Warn about global and non-accesible functions
82 ADD_DEFINITIONS("-Woverloaded-virtual")         # Warn about incidental overiding non-virtual base methods
83 ADD_DEFINITIONS("-Wnon-virtual-dtor")           # Warn about non-virtual destructor
84 ADD_DEFINITIONS("-Wctor-dtor-privacy")          # Warn about useless and non-constructible classes
85 #ADD_DEFINITIONS("-Wlong-long")                  # Do not allow using long long
86 #ADD_DEFINITIONS("-Wunreachable-code")           # Warn about unreachable code
87 ADD_DEFINITIONS("-Wfloat-equal")                # Do not accept comparing floating points with equal operator
88 ADD_DEFINITIONS("-Wabi")                        # Warn about possible ABI problems
89 ADD_DEFINITIONS("-Wswitch-enum")                # Check switch enumeration
90 ADD_DEFINITIONS("-Wformat=2")                   # Check printf formatting
91 ADD_DEFINITIONS("-Wundef")                      # Warn if an undefined identifier is evaluated in an @if directive.
92 ADD_DEFINITIONS("-Wshadow")                     # Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed
93 ADD_DEFINITIONS("-Wconversion")                 # Warn for implicit conversions that may alter a value
94 ADD_DEFINITIONS("-Wlogical-op")                 # Warn about suspicious uses of logical operators in expressions
95 #ADD_DEFINITIONS("-Waggregate-return")           # Warn if any functions that return structures or unions are defined or called.
96 ADD_DEFINITIONS("-Wmissing-field-initializers") # Warn if a structure's initializer has some fields missing.
97 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.
98 #ADD_DEFINITIONS("-Wmissing-include-dirs")       # Warn if a user-supplied include directory does not exist.
99 ADD_DEFINITIONS("-Wswitch-default")             # Warn whenever a switch statement does not have a default case.
100 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.
101 ADD_DEFINITIONS("-Wunused")                     # All the above -Wunused options combined.
102 ADD_DEFINITIONS("-Wstrict-overflow=5")          # Also warn about cases where the compiler reduces the magnitude of a constant involved in a comparison.
103 ADD_DEFINITIONS("-Wdisabled-optimization")      # Warn if a requested optimization pass is disabled.
104 ADD_DEFINITIONS("-std=c++0x")
105
106 #
107 # Core library files
108 #
109 # Define all core library headers and sources. As detail files
110 # are usually templated and though recompiled in each file, we
111 # have to compile full source for each target.
112 #
113
114 # Set names of binaries being created
115 SET(TARGET_DPL_EFL "lib${PROJECT_NAME}")
116 SET(TARGET_DPL_DB_EFL "lib${PROJECT_NAME}-db")
117 SET(TARGET_DPL_LOG_EFL "lib${PROJECT_NAME}-log")
118
119 macro(configure_and_install_pkg PKG_FILE)
120     CONFIGURE_FILE(${PKG_FILE}.in ${PKG_FILE} @ONLY)
121     INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG_FILE} DESTINATION lib/pkgconfig)
122 endmacro(configure_and_install_pkg)
123
124 ADD_SUBDIRECTORY(modules)
125 ADD_SUBDIRECTORY(build)
126