Merge branch 'ckm' into tizen
[platform/core/test/security-tests.git] / CMakeLists.txt
1 # Copyright (c) 2012-2020 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 # @file        CMakeLists.txt
16 # @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
17 # @author      Pawel Polawski (p.polawski@partner.samsung.com)
18 # @author      Piotr Sawicki (p.sawicki2@partner.samsung.com)
19 # @brief
20 #
21
22 ############################# Check minimum CMake version #####################
23
24 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
25 PROJECT("security-tests")
26
27 ############################# cmake packages ##################################
28
29 INCLUDE(FindPkgConfig)
30
31 ############################# compilation defines #############################
32
33 # EMPTY
34
35 ############################# compiler flags ##################################
36
37 SET(CMAKE_C_FLAGS              "-g")
38 SET(CMAKE_CXX_FLAGS            "-g -std=c++17")
39 SET(CMAKE_C_FLAGS_PROFILING    "-O0 -pg")
40 SET(CMAKE_CXX_FLAGS_PROFILING  "-O0 -pg")
41 SET(CMAKE_C_FLAGS_DEBUG        "-O0 -ggdb")
42 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -ggdb")
43 SET(CMAKE_C_FLAGS_RELEASE      "-O2")
44 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2")
45
46 SET(SMACK_ENABLE ON)
47
48 OPTION(DPL_LOG "DPL logs status" ON)
49 OPTION(DPL_WITH_DLOG "DPL DLOG backend" OFF)
50 IF(DPL_LOG)
51     MESSAGE(STATUS "Logging enabled for DPL")
52     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
53     IF(DPL_WITH_DLOG)
54         MESSAGE(STATUS "Enable DLOG backend")
55         ADD_DEFINITIONS("-DDPL_DLOG_ENABLED")
56     ENDIF(DPL_WITH_DLOG)
57 ELSE(DPL_LOG)
58     MESSAGE(STATUS "Logging disabled for DPL")
59 ENDIF(DPL_LOG)
60
61 OPTION(BUILD_ALL_TESTS "Build all tests" ON)
62 IF(BUILD_ALL_TESTS)
63     SET(BUILD_CKM ON)
64     SET(BUILD_SM ON)
65     SET(BUILD_CYNARA ON)
66     SET(BUILD_WEB ON)
67     SET(BUILD_YACA ON)
68     SET(BUILD_NETHER ON)
69     SET(BUILD_ODE ON)
70     SET(BUILD_E2EE_ADAPTATION_LAYER ON)
71 ENDIF(BUILD_ALL_TESTS)
72
73 # If supported for the target machine, emit position-independent code,suitable
74 # for dynamic linking and avoiding any limit on the size of the global offset
75 # table. This option makes a difference on the m68k, PowerPC and SPARC.
76 # (BJ: our ARM too?)
77 ADD_DEFINITIONS("-fPIC")
78
79 # Set the default ELF image symbol visibility to hidden - all symbols will be
80 # marked with this unless overridden within the code.
81 #ADD_DEFINITIONS("-fvisibility=hidden")
82
83 # Set compiler warning flags
84 ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
85 ADD_DEFINITIONS("-Wall")                        # Generate all warnings
86 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
87 ADD_DEFINITIONS("-Wno-variadic-macros")         # Inhibit variadic macros warnings (needed for ORM)
88 ADD_DEFINITIONS("-Wno-deprecated")               # No warnings about deprecated features
89 ADD_DEFINITIONS("-Wno-deprecated-declarations")               # No warnings about deprecated features
90 ADD_DEFINITIONS("-Wno-implicit-fallthrough")    # No warnings about switc() statements, often done on purpose
91 ADD_DEFINITIONS("-DCYNARA_DB_DIR=\"${CYNARA_DB_DIR}\"")
92 ADD_DEFINITIONS("-DAPP_USER=\"${APP_USER}\"")
93
94 # Enabler for popups; this should be done on system-level somewhere, but since it isn't
95 # and we already have such definition in security-manager, lets have it also here
96 ADD_DEFINITIONS("-DASKUSER_ENABLED")
97
98 IF(SMACK_ENABLE)
99     ADD_DEFINITIONS("-DWRT_SMACK_ENABLED")
100 ENDIF(SMACK_ENABLE)
101
102 IF(NOT DEFINED SHARE_INSTALL_PREFIX)
103         SET(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
104 ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
105
106 ############################# Targets names ###################################
107
108 SET(TARGET_CKM_TEST_COMMON "ckm-test-common")
109 SET(TARGET_CKM_TESTS "ckm-tests")
110 SET(TARGET_CKM_PRIVILEGED_TESTS "ckm-privileged-tests")
111 SET(TARGET_CKMI_TESTS "ckm-integration-tests")
112 SET(COMMON_TARGET_TEST "tests-common")
113 SET(TARGET_E2EE_TESTS "e2ee-tests")
114
115 ############################# subdirectories ##################################
116
117 ADD_SUBDIRECTORY(src)
118
119 IF(BUILD_ALL_TESTS)
120     ADD_SUBDIRECTORY(tests)
121 ENDIF(BUILD_ALL_TESTS)