Add conditional logs building
[platform/core/security/cynara.git] / test / CMakeLists.txt
1 # Copyright (c) 2014 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      Aleksander Zdyb <a.zdyb@partner.samsung.com>
17 # @brief       Cmake for tests
18 #
19
20 ############################# Check minimum CMake version #####################
21
22 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
23 PROJECT("cynara-tests")
24
25 ############################# cmake packages ##################################
26
27 INCLUDE(FindPkgConfig)
28
29 ############################# compiler flags ##################################
30
31 SET(CMAKE_C_FLAGS_DEBUG        "-g -O0 -ggdb")
32 SET(CMAKE_CXX_FLAGS_DEBUG      "-g -std=c++0x -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
33 SET(CMAKE_C_FLAGS_RELEASE      "-g -O2")
34 SET(CMAKE_CXX_FLAGS_RELEASE    "-g -std=c++0x -O2")
35
36 # Set compiler warning flags
37 ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
38 ADD_DEFINITIONS("-Wall")                        # Generate all warnings
39 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
40 ADD_DEFINITIONS("-DCYNARA_NO_LOGS")             # Disable building logs
41
42 MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
43
44 SET(TARGET_CYNARA_TESTS "cynara-tests")
45
46 PKG_CHECK_MODULES(PKGS REQUIRED gmock_main)
47
48 SET(CYNARA_SRC ${PROJECT_SOURCE_DIR}/../src)
49
50 SET(CYNARA_SOURCES_FOR_TESTS
51     ${CYNARA_SRC}/service/storage/Storage.cpp
52     ${CYNARA_SRC}/common/types/PolicyBucket.cpp
53     ${CYNARA_SRC}/service/storage/InMemoryStorageBackend.cpp
54     ${CYNARA_SRC}/service/storage/BucketDeserializer.cpp
55     ${CYNARA_SRC}/service/storage/StorageDeserializer.cpp
56     ${CYNARA_SRC}/service/storage/StorageSerializer.cpp
57     ${CYNARA_SRC}/common/types/PolicyKey.cpp
58     ${CYNARA_SRC}/common/types/PolicyType.cpp
59 )
60
61 SET(CYNARA_TESTS_SOURCES
62     common/exceptions/bucketrecordcorrupted.cpp
63     types/policykey.cpp
64     storage/storage/policies.cpp
65     storage/storage/check.cpp
66     storage/storage/buckets.cpp
67     storage/inmemorystoragebackend/inmemorystoragebackend.cpp
68     storage/inmemorystoragebackend/search.cpp
69     storage/inmemorystoragebackend/buckets.cpp
70     storage/serializer/bucket_load.cpp
71     storage/serializer/deserialize.cpp
72     storage/serializer/dump.cpp
73     common/types/policybucket.cpp
74     helpers.cpp
75 )
76
77 INCLUDE_DIRECTORIES(
78     ${PKGS_INCLUDE_DIRS}
79     ${CYNARA_SRC}/common
80     ${CYNARA_SRC}/include
81     ${CYNARA_SRC}/service
82 )
83
84 ADD_EXECUTABLE(${TARGET_CYNARA_TESTS}
85     ${CYNARA_SOURCES_FOR_TESTS}
86     ${CYNARA_TESTS_SOURCES}
87 )
88
89 TARGET_LINK_LIBRARIES(${TARGET_CYNARA_TESTS}
90     ${PKGS_LDFLAGS} ${PKGS_LIBRARIES}
91 )
92 INSTALL(TARGETS ${TARGET_CYNARA_TESTS} DESTINATION bin)