-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
109 lines (91 loc) · 4.01 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# Copyright (c) 2016-2020 Samsung Electronics Co., Ltd All Rights Reserved
#
# Contact: Krzysztof Jackiewicz <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
#
#
# @file CMakeLists.txt
# @author Dariusz Michaluk ([email protected])
#
CMAKE_MINIMUM_REQUIRED (VERSION 2.6.2)
PROJECT(yaca)
SET(VERSION "0.0.6")
## pkgconfig ###################################################################
INCLUDE(FindPkgConfig)
## default CMAKE_INSTALL_* variables ###########################################
INCLUDE(GNUInstallDirs)
## Color output if it's possible:
IF (( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9))
OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" ))
IF (YACA_BUILD_FORCE_COMPILER_COLORS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
ENDIF()
ENDIF()
## Compiler flags, depending on the build type #################################
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
ENDIF(NOT CMAKE_BUILD_TYPE)
## Print build information #####################################################
MESSAGE(STATUS "-------------------------------------------------")
MESSAGE(STATUS "Compiler: " ${CMAKE_C_COMPILER_ID})
MESSAGE(STATUS "Compiler version: " ${CMAKE_C_COMPILER_VERSION})
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
MESSAGE(STATUS "-------------------------------------------------")
SET(CMAKE_C_FLAGS_DEBUG "-std=c11 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
SET(CMAKE_C_FLAGS_RELEASE "-std=c11 -O2 -DNDEBUG")
SET(CMAKE_C_FLAGS_COVERAGE "-std=c11 -O0 -ggdb --coverage -Wp,-U_FORTIFY_SOURCE")
SET(CMAKE_CXX_FLAGS_COVERAGE "-std=c++14 -O0 -ggdb --coverage -Wp,-U_FORTIFY_SOURCE")
ADD_DEFINITIONS("-fPIC") # Position Independent Code
ADD_DEFINITIONS("-Werror") # Make all warnings into errors
ADD_DEFINITIONS("-Wall") # Generate all warnings
ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings
ADD_DEFINITIONS("-pedantic") # Be pedantic
ADD_DEFINITIONS("-pedantic-errors") # Make pedantic warnings into errors
ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
# Warn about documentation problems
ADD_DEFINITIONS("-Wdocumentation")
# Enable all diagnostics
#ADD_DEFINITIONS("-Weverything")
ENDIF()
## Subdirectories ##############################################################
SET(API_FOLDER ${PROJECT_SOURCE_DIR}/api/yaca)
SET(EXAMPLES_FOLDER ${PROJECT_SOURCE_DIR}/examples)
SET(SRC_FOLDER ${PROJECT_SOURCE_DIR}/src)
SET(TESTS_FOLDER ${PROJECT_SOURCE_DIR}/tests)
SET(PYTHON_FOLDER ${PROJECT_SOURCE_DIR}/python)
IF(NOT DEFINED LIB_INSTALL_DIR)
SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
ENDIF(NOT DEFINED LIB_INSTALL_DIR)
IF(NOT DEFINED INCLUDE_INSTALL_DIR)
SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
ENDIF(NOT DEFINED INCLUDE_INSTALL_DIR)
IF(NOT DEFINED BIN_INSTALL_DIR)
SET(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
ENDIF(NOT DEFINED BIN_INSTALL_DIR)
IF(NOT DEFINED SHARE_INSTALL_PREFIX)
SET(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
IF(NOT DEFINED EXAMPLES_DIR)
SET(EXAMPLES_DIR "${SHARE_INSTALL_PREFIX}/${PROJECT_NAME}/examples")
ENDIF(NOT DEFINED EXAMPLES_DIR)
ADD_SUBDIRECTORY(${SRC_FOLDER})
ADD_SUBDIRECTORY(${EXAMPLES_FOLDER})
IF(NOT WITHOUT_TESTS)
ADD_SUBDIRECTORY(${TESTS_FOLDER})
ENDIF(NOT WITHOUT_TESTS)
IF(NOT WITHOUT_PYTHON)
ADD_SUBDIRECTORY(${PYTHON_FOLDER})
ENDIF(NOT WITHOUT_PYTHON)