-
Notifications
You must be signed in to change notification settings - Fork 4
/
hadouken.cmake
162 lines (129 loc) · 6.57 KB
/
hadouken.cmake
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env cmake
# ______________________________________________________
# Contains the list of required includes for Hadouken.
#
# @file hadouken.cmake
# @author Mustafa Kemal GILOR <[email protected]>
# @date 14.02.2020
#
# Copyright (c) Nettsi Informatics Technology Inc. All rights reserved.
# Licensed under the Apache 2.0 License. See LICENSE in the project root for license information.
#
# SPDX-License-Identifier: Apache 2.0
# ______________________________________________________
string(TIMESTAMP HADOUKEN_LOAD_START "%s" UTC)
set(HDK_ROOT_PROJECT_NAME ${PROJECT_NAME} )
set(HDK_ROOT_PROJECT_VERSION ${PROJECT_VERSION} )
set(HDK_ROOT_PROJECT_DESCRIPTION ${PROJECT_DESCRIPTION} )
set(HDK_ROOT_PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} )
set(HDK_ROOT_PROJECT_BINARY_DIR ${PROJECT_BINARY_DIR} )
set(HDK_ROOT_PROJECT_HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL} )
set(HDK_ROOT_PROJECT_LANGUAGES ${PROJECT_LANGUAGES} )
set(HDK_ROOT_DIRECTORY ${HDK_ROOT_PROJECT_SOURCE_DIR}/.hadouken)
# Add hadouken cmake modules as cmake modules to parent project
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/)
# Add custom find module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/find)
# Common utility functions module
include(misc/Utility)
# Capitalize and sanitize project name
hdk_capsan_name(${HDK_ROOT_PROJECT_NAME} HDK_ROOT_PROJECT_NAME_UPPER)
# Hadouken options
set(${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_DEBUG "-O0 -g" )
set(${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" )
set(${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" )
set(${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
# Check if user specified a conan profile file
if (${HDK_ROOT_PROJECT_NAME_UPPER}_HADOUKEN_CONAN_PROFILE_FILE AND NOT ${${HDK_ROOT_PROJECT_NAME_UPPER}_HADOUKEN_CONAN_PROFILE_FILE} STREQUAL "")
set(${HDK_ROOT_PROJECT_NAME_UPPER}_HADOUKEN_CONAN_PROFILE_LINE "PROFILE ${${HDK_ROOT_PROJECT_NAME_UPPER}_HADOUKEN_CONAN_PROFILE_FILE}")
else()
set(${HDK_ROOT_PROJECT_NAME_UPPER}_HADOUKEN_CONAN_PROFILE_LINE "")
endif()
# Enable testing for the project
enable_testing()
# Warn on deprecated logs
option(CMAKE_WARN_DEPRECATED ON)
# Export compile commands for other tool usage
option(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Print colorful makefile output
option(CMAKE_COLOR_MAKEFILE ON)
# Recommended setting for symbol visibility.
if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
endif()
# Recommended setting for inline symbol visibility.
option(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
# Visibility policy
cmake_policy(SET CMP0063 NEW)
# `Adding link libraries to target which is not built in current directory` policy
# (Required for coverage link library injection)
cmake_policy(SET CMP0079 NEW)
# This somehow tends to be unset, and causes third party library headers to generate warnings
# which results in build failure.
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
# Logging module
include(misc/Log)
# Banner module
include(misc/Banner)
# Set logging context
hdk_log_set_context("hadouken")
hdk_log_status("-------------------------- hadouken bootstrap start -----------------------------")
hdk_log_status("Configuring project `${HDK_ROOT_PROJECT_NAME}` with CMake ${CMAKE_VERSION}")
hdk_log_unset_context()
# Discover all core modules
file(GLOB CORE_MODULES "${PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/core/*.cmake")
# Discover all toolconf modules
file(GLOB TOOLCONF_MODULES "${PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/toolconf/*.cmake")
# Discover all wrapper modules
file(GLOB WRAPPER_MODULES "${PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/wrappers/*.cmake")
hdk_log_set_context("hadouken.load.core")
hdk_log_debug("loading core modules..")
foreach(MODULE_FN IN LISTS CORE_MODULES)
hdk_log_trace("hadouken: loading core module: ${MODULE_FN}")
include(${MODULE_FN})
endforeach()
hdk_log_debug("core modules loaded")
hdk_log_unset_context()
hdk_set_build_variant()
if(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_COVERAGE OR ${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_GCOV OR ${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_LLVM_COV)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
hdk_log_status("Code coverage results with an optimised (non-Debug) build may be misleading")
endif()
endif()
if(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_COVERAGE)
if(${HADOUKEN_COMPILER} STREQUAL "GCC")
hdk_log_debug("GCC compiler detected, GCov is activated for test coverage.")
set(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_GCOV ON CACHE BOOL "Enable/disable gcov")
set(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_LLVM_COV OFF CACHE BOOL "Enable/disable llvm-cov")
elseif(${HADOUKEN_COMPILER} STREQUAL "CLANG")
hdk_log_debug("Clang compiler detected, LLVM Cov is activated for test coverage.")
set(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_GCOV OFF CACHE BOOL "Enable/disable gcov")
set(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_USE_LLVM_COV ON CACHE BOOL "Enable/disable llvm-cov")
endif()
endif()
hdk_parameter_default_value(${HDK_ROOT_PROJECT_NAME_UPPER}_TOOLCONF_COVERAGE_HTML_TITLE " Code Coverage Report")
hdk_log_set_context("hadouken.load.wrapper")
list(LENGTH WRAPPER_MODULES WRAPPER_MODULES_SIZE)
hdk_log_debug("..loading wrapper modules (${WRAPPER_MODULES_SIZE})..")
foreach(MODULE_FN IN LISTS WRAPPER_MODULES)
hdk_log_trace("hadouken: loading module: ${MODULE_FN}")
include(${MODULE_FN})
endforeach()
hdk_log_debug(".. wrapper modules loaded")
hdk_log_unset_context()
hdk_log_set_context("hadouken.toolconf")
list(LENGTH TOOLCONF_MODULES TOOLCONF_MODULES_SIZE)
hdk_log_debug("..loading tool configuration modules (${TOOLCONF_MODULES_SIZE})..")
foreach(MODULE_FN IN LISTS TOOLCONF_MODULES)
hdk_log_trace("hadouken: loading tool configuration module: ${MODULE_FN}")
include(${MODULE_FN})
endforeach()
hdk_log_debug(".. tool configuration modules loaded")
hdk_log_unset_context()
include(FeatureCheck)
string(TIMESTAMP HADOUKEN_LOAD_END "%s" UTC)
math(EXPR HADOUKEN_LOAD_DURATION "${HADOUKEN_LOAD_END}-${HADOUKEN_LOAD_START}")
hdk_log_set_context("hadouken")
hdk_log_status("Load completed in ${HADOUKEN_LOAD_DURATION} second(s)")
hdk_log_unset_context()
hdk_log_status("-------------------------- hadouken bootstrap end -----------------------------")