075a7574f6dafff2411b141f8acc2ff4ffef5170
[platform/core/security/device-certificate-manager.git] / tests / CMakeLists.txt
1 # Copyright (c) 2020 - 2021 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        tests/CMakeLists.txt
16 # @author      Dariusz Michaluk <d.michaluk@samsung.com>
17 # @author      Jaroslaw Pelczar <j.pelczar@samsung.com>
18
19 SET(TARGET_TESTS "device-certificate-manager-tests")
20
21 IF (CMAKE_BUILD_TYPE MATCHES "COVERAGE")
22
23         # coverage data
24         SET(COVERAGE_BUILD_DIR
25                 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET_TESTS}.dir/
26         )
27
28         # install gcno files
29         INSTALL(
30                 DIRECTORY ${COVERAGE_BUILD_DIR}/
31                 DESTINATION ${COVERAGE_DIR}
32                 FILES_MATCHING PATTERN "*.gcno"
33         )
34
35         # install code coverage automation script
36         CONFIGURE_FILE(device-certificate-manager-coverage.sh.in device-certificate-manager-coverage.sh @ONLY)
37         INSTALL(
38                 PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/device-certificate-manager-coverage.sh
39                 DESTINATION ${CMAKE_INSTALL_BINDIR}
40         )
41
42 ENDIF (CMAKE_BUILD_TYPE MATCHES "COVERAGE")
43
44 FIND_PACKAGE(Threads REQUIRED)
45 FIND_PACKAGE(Protobuf REQUIRED)
46
47 FIND_PACKAGE(Boost REQUIRED
48         COMPONENTS
49         unit_test_framework)
50
51 PKG_CHECK_MODULES(TEST_DEPS REQUIRED dlog libsmack)
52
53 INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS} ${TEST_DEPS_INCLUDE_DIRS})
54 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS} ${TEST_DEPS_LIBRARY_DIRS})
55 INCLUDE_DIRECTORIES(../src/dcm-client ../src/dcm-daemon ../src/shared ../src/include)
56
57 ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
58
59 PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ../src/dcm-client/dcm_support.proto)
60
61 ADD_EXECUTABLE(${TARGET_TESTS}
62         device_certificate_manager_tests.cpp
63         api_test.cpp
64         colour_log_formatter.cpp
65         shared_test.cpp
66         ../src/dcm-client/dcm_client.cpp
67         ../src/dcm-client/device_certificate_manager.cpp
68         ../src/dcm-client/device_certificate_manager_ext.cpp
69         ../src/shared/log.cpp
70         ../src/shared/protobuf_asio.cpp
71         ../src/shared/bundle.cpp
72         ${PROTO_SRCS}
73         ${PROTO_HDRS})
74
75 TARGET_LINK_LIBRARIES(${TARGET_TESTS}
76         ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}
77         ${CMAKE_THREAD_LIBS_INIT}
78         ${TEST_DEPS_LIBRARIES}
79         ${PROTOBUF_LITE_LIBRARIES})
80
81 INSTALL(TARGETS
82         ${TARGET_TESTS}
83         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})