Remove unneeded compilation flags
[platform/core/security/device-certificate-manager.git] / CMakeLists.txt
1 # Copyright (c) 2017 - 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      Dariusz Michaluk <d.michaluk@samsung.com>
17 # @author      Jaroslaw Pelczar <j.pelczar@samsung.com>
18
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
20
21 ##### Configure project version when using
22 ##### outdated tools like CMake v2
23
24 IF(POLICY CMP0048)
25         CMAKE_POLICY(SET CMP0048 NEW)
26 ENDIF()
27
28 IF(POLICY CMP0069)
29         CMAKE_POLICY(SET CMP0069 NEW)
30 ENDIF()
31
32 IF(CMAKE_VERSION VERSION_LESS 3.0)
33         PROJECT(device-certificate-manager CXX C)
34         SET(PROJECT_VERSION     "2.0")
35 ELSE()
36         PROJECT(device-certificate-manager VERSION 2.0 LANGUAGES C CXX)
37 ENDIF()
38
39 INCLUDE(GNUInstallDirs)
40
41 IF(NOT (CMAKE_VERSION VERSION_LESS 3.9))
42         INCLUDE(CheckIPOSupported)
43         check_ipo_supported(RESULT IPO_ALLOWED)
44 ELSE()
45         SET(IPO_ALLOWED YES)
46 ENDIF()
47
48 find_package(Threads REQUIRED)
49
50 INCLUDE(cmake/CheckFrameworks.cmake)
51
52 IF(NOT CMAKE_BUILD_TYPE)
53         SET(CMAKE_BUILD_TYPE "RELEASE")
54 ENDIF(NOT CMAKE_BUILD_TYPE)
55
56 SET(CMAKE_C_FLAGS_DEBUG        "-std=c11 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
57 SET(CMAKE_CXX_FLAGS_DEBUG      "-std=c++17 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
58 SET(CMAKE_C_FLAGS_RELEASE      "-std=c11 -O2 -DNDEBUG")
59 SET(CMAKE_CXX_FLAGS_RELEASE    "-std=c++17 -O2 -DNDEBUG")
60
61 ADD_DEFINITIONS("-Werror")
62 ADD_DEFINITIONS("-Wall")
63 ADD_DEFINITIONS("-Wextra")
64
65 SET(CMAKE_POSITION_INDEPENDENT_CODE "True")
66 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
67
68 option(ENABLE_SYSTEMD_SUPPORT "Enable support for systemd" ON)
69
70 IF(ENABLE_SYSTEMD_SUPPORT AND NOT SYSTEMD_FOUND)
71         message(FATAL_ERROR "systemd support required but systemd not found")
72 ENDIF()
73
74 include_directories(${CMAKE_CURRENT_BINARY_DIR})
75 include_directories(shared)
76
77 SET(DCM_UNIX_SOCKET_PATH "/run/device-certificate-manager.socket")
78 add_definitions(-DDCM_UNIX_SOCKET_PATH="${DCM_UNIX_SOCKET_PATH}")
79
80 add_subdirectory(dcm-client)
81 add_subdirectory(dcm-daemon)
82 add_subdirectory(pkgconfig)
83 add_subdirectory(rpm)
84 add_subdirectory(systemd)
85 add_subdirectory(tests)