Add debug compilation mode
[platform/core/security/nice-lad.git] / CMakeLists.txt
1 # Copyright (c) 2015 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@samsung.com>
17 # @author      Oskar Ĺšwitalski <o.switalski@samsung.com>
18 #
19
20 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
21 PROJECT(nice-lad)
22
23 OPTION(WITH_TESTS "Build tests" ON)
24
25 ############################# compiler flags ##################################
26
27 SET(CMAKE_CXX_FLAGS_PROFILING  "-O0 -g -pg")
28 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -g -ggdb")
29 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -g")
30 SET(CMAKE_CXX_FLAGS_CCOV       "-O2 -g --coverage")
31
32 # Check for C++11 support and enable proper compilation flags
33 INCLUDE(CheckCXXCompilerFlag)
34 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
35 IF(COMPILER_SUPPORTS_CXX11)
36     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
37 ELSE()
38     CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
39     IF(COMPILER_SUPPORTS_CXX0X)
40         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
41     ELSE()
42         MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
43     ENDIF()
44 ENDIF()
45
46 IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
47     ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
48 ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
49
50 SET(BIN_DIR
51     "${CMAKE_INSTALL_PREFIX}/bin"
52     CACHE PATH
53     "User executables directory"
54 )
55
56 SET(SBIN_DIR
57     "${CMAKE_INSTALL_PREFIX}/sbin"
58     CACHE PATH
59     "System admin executables directory"
60 )
61
62 SET(SYS_CONFIG_DIR
63     "${CMAKE_INSTALL_PREFIX}/etc"
64     CACHE PATH
65     "Read-only single-machine data directory"
66 )
67
68 INCLUDE(FindPkgConfig)
69
70 SET(TARGET_NICE_LAD "nice-lad")
71
72 ADD_SUBDIRECTORY(src)
73 ADD_SUBDIRECTORY(conf)
74
75 IF(WITH_TESTS)
76     SET(TARGET_NICE_LAD_TESTS "nice-lad-tests")
77     ADD_SUBDIRECTORY(tests)
78 ENDIF(WITH_TESTS)