Rewrite cmake infrastructure
[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(CMAKE_VERSION VERSION_LESS 3.0)
29         PROJECT(device-certificate-manager CXX C)
30         SET(PROJECT_VERSION     "2.0")
31 ELSE()
32         PROJECT(device-certificate-manager VERSION 2.0 LANGUAGES C CXX)
33 ENDIF()
34
35 INCLUDE(GNUInstallDirs)
36 INCLUDE(FindPkgConfig)
37 INCLUDE(CheckLibraryExists)
38 INCLUDE(GenerateExportHeader)
39
40 IF(NOT CMAKE_BUILD_TYPE)
41         SET(CMAKE_BUILD_TYPE "RELEASE")
42 ENDIF(NOT CMAKE_BUILD_TYPE)
43
44 SET(CMAKE_C_FLAGS_DEBUG        "-std=c11 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
45 SET(CMAKE_CXX_FLAGS_DEBUG      "-std=c++17 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
46 SET(CMAKE_C_FLAGS_RELEASE      "-std=c11 -O2 -DNDEBUG")
47 SET(CMAKE_CXX_FLAGS_RELEASE    "-std=c++17 -O2 -DNDEBUG")
48
49 ADD_DEFINITIONS("-Werror")
50 ADD_DEFINITIONS("-Wall")
51 ADD_DEFINITIONS("-Wextra")
52
53 SET(CMAKE_POSITION_INDEPENDENT_CODE "True")
54 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
55
56 SET(DCM_UNIX_SOCKET_PATH "/run/device-certificate-manager.socket")
57 ADD_DEFINITIONS(-DDCM_UNIX_SOCKET_PATH="${DCM_UNIX_SOCKET_PATH}")
58
59 INCLUDE_DIRECTORIES(shared)
60 ADD_SUBDIRECTORY(dcm-client)
61 ADD_SUBDIRECTORY(dcm-daemon)
62 ADD_SUBDIRECTORY(pkgconfig)
63 ADD_SUBDIRECTORY(rpm)
64 ADD_SUBDIRECTORY(systemd)
65 ADD_SUBDIRECTORY(tests)