1 # Copyright (c) 2017 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # @file CMakeLists.txt
16 # @author Dariusz Michaluk <d.michaluk@samsung.com>
17 # @author Jaroslaw Pelczar <j.pelczar@samsung.com>
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
21 ##### Configure project version when using
22 ##### outdated tools like CMake v2
25 CMAKE_POLICY(SET CMP0048 NEW)
29 CMAKE_POLICY(SET CMP0069 NEW)
32 IF(CMAKE_VERSION VERSION_LESS 3.0)
33 PROJECT(device-certificate-manager CXX C)
34 SET(PROJECT_VERSION "2.0")
36 PROJECT(device-certificate-manager VERSION 2.0 LANGUAGES C CXX)
39 INCLUDE(GNUInstallDirs)
41 IF(NOT (CMAKE_VERSION VERSION_LESS 3.9))
42 INCLUDE(CheckIPOSupported)
43 check_ipo_supported(RESULT IPO_ALLOWED)
48 find_package(Threads REQUIRED)
50 INCLUDE(cmake/CheckFrameworks.cmake)
52 IF(NOT CMAKE_BUILD_TYPE)
53 SET(CMAKE_BUILD_TYPE "RELEASE")
54 ENDIF(NOT CMAKE_BUILD_TYPE)
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")
61 ADD_DEFINITIONS("-Werror")
62 ADD_DEFINITIONS("-Wall")
63 ADD_DEFINITIONS("-Wextra")
65 SET(CMAKE_POSITION_INDEPENDENT_CODE "True")
66 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
68 option(ENABLE_SYSTEMD_SUPPORT "Enable support for systemd" ON)
70 IF(ENABLE_SYSTEMD_SUPPORT AND NOT SYSTEMD_FOUND)
71 message(FATAL_ERROR "systemd support required but systemd not found")
74 include_directories(${CMAKE_CURRENT_BINARY_DIR})
75 include_directories(shared)
77 SET(DCM_UNIX_SOCKET_PATH "/run/device-certificate-manager.socket")
78 add_definitions(-DDCM_UNIX_SOCKET_PATH="${DCM_UNIX_SOCKET_PATH}")
80 add_subdirectory(dcm-client)
81 add_subdirectory(dcm-daemon)
82 add_subdirectory(pkgconfig)
84 add_subdirectory(systemd)
85 add_subdirectory(tests)