diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-06-24 22:56:07 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-01 08:35:44 +0000 |
commit | 1a54be06cd359257478b584611f34058d21fe723 (patch) | |
tree | db3d6ca2dfa2a87ae2efdac6e412c2b780a64009 /CMakeLists.txt | |
parent | 706fad1ce88c2104009a3835ee343ff9d8ec8b79 (diff) |
Simplify Travis CI builds.
Have one script per build. This means more duplication between the
scripts, but it's much easier to understand and to run locally.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 126 |
1 files changed, 13 insertions, 113 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cc55a235..8cd26f43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -52,7 +52,6 @@ message("SOVERSION: ${SOVERSION}") | |||
52 | # | 52 | # |
53 | ################################################################################ | 53 | ################################################################################ |
54 | 54 | ||
55 | include(AddCompilerFlag) | ||
56 | include(ApiDsl) | 55 | include(ApiDsl) |
57 | include(ModulePackage) | 56 | include(ModulePackage) |
58 | include(StrictAbi) | 57 | include(StrictAbi) |
@@ -63,25 +62,22 @@ if(APPLE) | |||
63 | endif() | 62 | endif() |
64 | 63 | ||
65 | if(UNIX) | 64 | if(UNIX) |
66 | if(CMAKE_SYSTEM_NAME MATCHES ".*Linux") | 65 | if(CMAKE_SYSTEM_NAME MATCHES ".*Linux") |
67 | set(LINUX TRUE) | 66 | set(LINUX TRUE) |
68 | elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*") | 67 | elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*") |
69 | set(OPENBSD TRUE) | 68 | set(OPENBSD TRUE) |
70 | elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*") | 69 | elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*") |
71 | set(NETBSD TRUE) | 70 | set(NETBSD TRUE) |
72 | elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*|FreeBSD") | 71 | elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*|FreeBSD") |
73 | set(FREEBSD TRUE) | 72 | set(FREEBSD TRUE) |
74 | endif() | 73 | endif() |
75 | endif() | 74 | endif() |
76 | 75 | ||
77 | enable_testing() | 76 | enable_testing() |
78 | 77 | ||
79 | set(CMAKE_MACOSX_RPATH ON) | 78 | set(CMAKE_MACOSX_RPATH ON) |
80 | 79 | ||
81 | if(${CMAKE_VERSION} VERSION_LESS "3.1.0") | 80 | if(NOT ${CMAKE_VERSION} VERSION_LESS "3.1.0") |
82 | add_cflag("-std=c99") | ||
83 | add_cxxflag("-std=c++11") | ||
84 | else() | ||
85 | # Set standard version for compiler. | 81 | # Set standard version for compiler. |
86 | set(CMAKE_C_STANDARD 99) | 82 | set(CMAKE_C_STANDARD 99) |
87 | set(CMAKE_CXX_STANDARD 11) | 83 | set(CMAKE_CXX_STANDARD 11) |
@@ -92,93 +88,9 @@ else() | |||
92 | message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") | 88 | message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") |
93 | endif() | 89 | endif() |
94 | 90 | ||
95 | if(NOT MSVC) | 91 | option(TRACE "Enable DEBUG level logging (default)" ON) |
96 | # Warn on non-ISO C. | 92 | if(DEBUG) |
97 | add_cflag("-pedantic") | 93 | set(MIN_LOGGER_LEVEL DEBUG) |
98 | |||
99 | option(ERROR_ON_WARNING "Make compilation error on a warning" OFF) | ||
100 | if(ERROR_ON_WARNING) | ||
101 | add_flag("-Werror") | ||
102 | endif() | ||
103 | |||
104 | option(COVERAGE "Track code coverage" OFF) | ||
105 | if(COVERAGE) | ||
106 | add_flag("-fprofile-instr-generate") | ||
107 | add_flag("-fcoverage-mapping") | ||
108 | endif() | ||
109 | |||
110 | option(DEBUG "Enable assertions and other debugging facilities" OFF) | ||
111 | if(DEBUG) | ||
112 | set(MIN_LOGGER_LEVEL DEBUG) | ||
113 | add_cflag("-g3") | ||
114 | if(MINGW) | ||
115 | # Allows wine to display source code file names and line numbers on crash in its backtrace | ||
116 | add_flag("-gdwarf-2") | ||
117 | endif() | ||
118 | # Crash on signed integer overflow. | ||
119 | add_flag("-ftrapv") | ||
120 | endif() | ||
121 | |||
122 | option(WARNINGS "Enable additional compiler warnings" ON) | ||
123 | if(WARNINGS) | ||
124 | # Add all warning flags we can. | ||
125 | add_flag("-Wall") | ||
126 | add_flag("-Wextra") | ||
127 | add_flag("-Weverything") | ||
128 | |||
129 | # Disable specific warning flags for both C and C++. | ||
130 | |||
131 | # TODO(iphydf): Clean these up. Probably all of these are actual bugs. | ||
132 | add_flag("-Wno-cast-align") | ||
133 | # Very verbose, not very useful. This warns about things like int -> uint | ||
134 | # conversions that change sign without a cast and narrowing conversions. | ||
135 | add_flag("-Wno-conversion") | ||
136 | # TODO(iphydf): Check enum values when received from the user, then assume | ||
137 | # correctness and remove this suppression. | ||
138 | add_flag("-Wno-covered-switch-default") | ||
139 | # Due to clang's tolower() macro being recursive | ||
140 | # https://github.com/TokTok/c-toxcore/pull/481 | ||
141 | add_flag("-Wno-disabled-macro-expansion") | ||
142 | # We don't put __attribute__ on the public API. | ||
143 | add_flag("-Wno-documentation-deprecated-sync") | ||
144 | # Bootstrap daemon does this. | ||
145 | add_flag("-Wno-format-nonliteral") | ||
146 | # struct Foo foo = {0}; is a common idiom. | ||
147 | add_flag("-Wno-missing-field-initializers") | ||
148 | # Useful sometimes, but we accept padding in structs for clarity. | ||
149 | # Reordering fields to avoid padding will reduce readability. | ||
150 | add_flag("-Wno-padded") | ||
151 | # This warns on things like _XOPEN_SOURCE, which we currently need (we | ||
152 | # probably won't need these in the future). | ||
153 | add_flag("-Wno-reserved-id-macro") | ||
154 | # TODO(iphydf): Clean these up. They are likely not bugs, but still | ||
155 | # potential issues and probably confusing. | ||
156 | add_flag("-Wno-sign-compare") | ||
157 | # Our use of mutexes results in a false positive, see 1bbe446. | ||
158 | add_flag("-Wno-thread-safety-analysis") | ||
159 | # File transfer code has this. | ||
160 | add_flag("-Wno-type-limits") | ||
161 | # Callbacks often don't use all their parameters. | ||
162 | add_flag("-Wno-unused-parameter") | ||
163 | # libvpx uses __attribute__((unused)) for "potentially unused" static | ||
164 | # functions to avoid unused static function warnings. | ||
165 | add_flag("-Wno-used-but-marked-unused") | ||
166 | # We use variable length arrays a lot. | ||
167 | add_flag("-Wno-vla") | ||
168 | |||
169 | # Disable specific warning flags for C++. | ||
170 | |||
171 | # Comma at end of enum is supported everywhere we run. | ||
172 | add_cxxflag("-Wno-c++98-compat-pedantic") | ||
173 | # TODO(iphydf): Stop using flexible array members. | ||
174 | add_cxxflag("-Wno-c99-extensions") | ||
175 | # We're C-compatible, so use C style casts. | ||
176 | add_cxxflag("-Wno-old-style-cast") | ||
177 | |||
178 | # Downgrade to warning so we still see it. | ||
179 | add_flag("-Wno-error=unreachable-code") | ||
180 | add_flag("-Wno-error=unused-variable") | ||
181 | endif() | ||
182 | endif() | 94 | endif() |
183 | 95 | ||
184 | option(TRACE "Enable TRACE level logging (expensive, for network debugging)" OFF) | 96 | option(TRACE "Enable TRACE level logging (expensive, for network debugging)" OFF) |
@@ -190,18 +102,6 @@ if(MIN_LOGGER_LEVEL) | |||
190 | add_definitions(-DMIN_LOGGER_LEVEL=LOG_${MIN_LOGGER_LEVEL}) | 102 | add_definitions(-DMIN_LOGGER_LEVEL=LOG_${MIN_LOGGER_LEVEL}) |
191 | endif() | 103 | endif() |
192 | 104 | ||
193 | option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF) | ||
194 | if(ASAN) | ||
195 | add_cflag("-fsanitize=address") | ||
196 | add_dllflag("-fsanitize=address") | ||
197 | endif() | ||
198 | |||
199 | if(LINUX) | ||
200 | add_dllflag("-Wl,-z,defs") | ||
201 | else() | ||
202 | add_dllflag("-undefined error") | ||
203 | endif() | ||
204 | |||
205 | option(USE_IPV6 "Use IPv6 in tests" ON) | 105 | option(USE_IPV6 "Use IPv6 in tests" ON) |
206 | if(NOT USE_IPV6) | 106 | if(NOT USE_IPV6) |
207 | add_definitions(-DUSE_IPV6=0) | 107 | add_definitions(-DUSE_IPV6=0) |