This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
otcommon-configure-target.cmake
137 lines (126 loc) · 3.25 KB
/
otcommon-configure-target.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
# Copyright (c) 2020-2022 The Open-Transactions developers
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
function(otcommon_configure_target target_name)
include(otcommon-apply-defines)
otcommon_apply_defines(${target_name})
set_target_properties(
${target_name}
PROPERTIES
C_STANDARD "${${PROJECT_NAME}_C_STANDARD}"
CXX_STANDARD "${${PROJECT_NAME}_CXX_STANDARD}"
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
)
if(MSVC)
set_target_properties(
${target_name} PROPERTIES MSVC_RUNTIME_LIBRARY
"${${PROJECT_NAME}_MSVC_RUNTIME_LIBRARY}"
)
target_compile_options(
${target_name}
PUBLIC "/EHsc"
PRIVATE
"/W3"
"/Zc:char8_t-"
"/bigobj"
"/utf-8"
"/wd4068"
"/wd4250"
)
if(${PROJECT_NAME}_PEDANTIC_COMPILER_FLAGS)
target_compile_options(${target_name} PRIVATE "/WX")
endif()
else()
target_compile_options(
${target_name}
PRIVATE
"-W"
"-Wall"
"-Wextra"
"-Wno-pragmas"
"-Wno-unknown-pragmas"
"-pedantic"
)
if(${PROJECT_NAME}_PEDANTIC_COMPILER_FLAGS)
target_compile_options(
${target_name} PRIVATE "-Werror" "-pedantic-errors"
)
endif()
endif()
if(${CMAKE_CXX_COMPILER_ID}
MATCHES
GNU
)
target_compile_options(
${target_name}
PRIVATE
"-Wcast-align"
"-Wdouble-promotion"
"-Wduplicated-branches"
"-Wduplicated-cond"
"-Wformat=2"
"-Winit-self"
"-Wlogical-op"
"-Wmissing-declarations"
"-Wmissing-include-dirs"
"-Wnull-dereference"
"-Wrestrict"
"-Wshadow"
"-Wswitch-default"
"-Wswitch-enum"
"-Wundef"
"-Wunused-macros"
)
endif()
if(${CMAKE_CXX_COMPILER_ID}
MATCHES
Clang
)
target_compile_options(
${target_name}
PRIVATE
"-Weverything"
"-Wno-c++98-compat"
"-Wno-c++98-compat-pedantic"
"-Wno-covered-switch-default"
"-Wno-exit-time-destructors"
"-Wno-global-constructors"
"-Wno-inline-namespace-reopened-noninline"
"-Wno-missing-prototypes"
"-Wno-missing-variable-declarations"
"-Wno-padded"
"-Wno-undefined-func-template"
"-Wno-unknown-warning-option"
"-Wno-weak-template-vtables"
"-Wno-weak-vtables"
)
endif()
endfunction()
function(otcommon_configure_c_target target_name)
otcommon_configure_target(${target_name})
endfunction()
function(otcommon_configure_cxx_target target_name)
otcommon_configure_target(${target_name})
if(NOT MSVC)
target_compile_options(${target_name} PRIVATE "-fno-char8_t")
endif()
if(${CMAKE_CXX_COMPILER_ID}
MATCHES
GNU
)
target_compile_options(
${target_name}
PRIVATE
"-Wctor-dtor-privacy"
"-Weffc++"
"-Wnoexcept"
"-Wold-style-cast"
"-Woverloaded-virtual"
"-Wstrict-null-sentinel"
"-Wsuggest-override"
)
endif()
endfunction()