@@ -173,30 +173,40 @@ IF(UNIX)
173
173
# Default GCC flags
174
174
IF (CMAKE_COMPILER_IS_GNUCC )
175
175
SET (COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized" )
176
- SET (CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS} " )
177
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS} " )
176
+ STRING (APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS} " )
177
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " ${COMMON_C_FLAGS} " )
178
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMMON_C_FLAGS} " )
179
+ # MariaDB uses -O3 for release builds
180
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
181
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
178
182
ENDIF ()
179
183
IF (CMAKE_COMPILER_IS_GNUCXX )
180
184
SET (COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized" )
181
- SET (CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS} " )
182
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS} " )
185
+ STRING (APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS} " )
186
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " ${COMMON_CXX_FLAGS} " )
187
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMMON_CXX_FLAGS} " )
188
+ # MariaDB uses -O3 for release builds
189
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} " )
190
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )
183
191
ENDIF ()
184
192
185
193
# IBM Z flags
186
194
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "s390x" )
187
195
IF (RPM MATCHES "(rhel|centos)6" OR RPM MATCHES "(suse|sles)11" )
188
- SET (z_flags "-funroll-loops -march=z9-109 -mtune=z10 " )
196
+ SET (z_flags "-funroll-loops -march=z9-109 -mtune=z10" )
189
197
ELSEIF (RPM MATCHES "(rhel|centos)7" OR RPM MATCHES "(suse|sles)12" )
190
- SET (z_flags "-funroll-loops -march=z196 -mtune=zEC12 " )
198
+ SET (z_flags "-funroll-loops -march=z196 -mtune=zEC12" )
191
199
ELSE ()
192
200
SET (z_flags "" )
193
201
ENDIF ()
194
202
195
203
IF (CMAKE_COMPILER_IS_GNUCC )
196
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "${z_flags}${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
204
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " ${z_flags} " )
205
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${z_flags} " )
197
206
ENDIF ()
198
207
IF (CMAKE_COMPILER_IS_GNUCXX )
199
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${z_flags}${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )
208
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " ${z_flags} " )
209
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${z_flags} " )
200
210
ENDIF ()
201
211
UNSET (z_flags )
202
212
ENDIF ()
@@ -207,11 +217,13 @@ IF(UNIX)
207
217
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "ia64" )
208
218
SET (COMMON_C_FLAGS "+DSitanium2 -mt -AC99" )
209
219
SET (COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa" )
210
- SET (CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS} " )
211
- SET (CMAKE_CXX_FLAGS_DEBUG "+O0 -g ${COMMON_CXX_FLAGS} " )
212
- # We have seen compiler bugs with optimisation and -g, so disabled for now
213
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_C_FLAGS} " )
214
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_CXX_FLAGS} " )
220
+ STRING (APPEND CMAKE_C_FLAGS_DEBUG " +O0 -g ${COMMON_C_FLAGS} " )
221
+ STRING (APPEND CMAKE_CXX_FLAGS_DEBUG " +O0 -g ${COMMON_CXX_FLAGS} " )
222
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " +O0 -g ${COMMON_C_FLAGS} " )
223
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " +O0 -g ${COMMON_CXX_FLAGS} " )
224
+ # We have seen compiler bugs with optimisation and -g, so disabled for now
225
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " +O2 ${COMMON_C_FLAGS} " )
226
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " +O2 ${COMMON_CXX_FLAGS} " )
215
227
ENDIF ()
216
228
ENDIF ()
217
229
SET (WITH_SSL no )
@@ -226,24 +238,40 @@ IF(UNIX)
226
238
SET (COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch" )
227
239
SET (COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch" )
228
240
ENDIF ()
229
- SET (CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS} " )
230
- SET (CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS} " )
231
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS} " )
232
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS} " )
241
+ STRING (APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS} " )
242
+ STRING (APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS} " )
243
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " -unroll2 -ip ${COMMON_C_FLAGS} " )
244
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " -unroll2 -ip ${COMMON_CXX_FLAGS} " )
245
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -unroll2 -ip ${COMMON_C_FLAGS} " )
246
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -unroll2 -ip ${COMMON_CXX_FLAGS} " )
247
+
248
+ # MariaDB uses -O3 for release builds.
249
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
250
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} " )
251
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
252
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )
233
253
SET (WITH_SSL no )
234
254
ENDIF ()
235
255
ENDIF ()
236
256
237
257
# Default Clang flags
238
258
IF (CMAKE_C_COMPILER_ID MATCHES "Clang" )
239
259
SET (COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int" )
240
- SET (CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS} " )
241
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS} " )
260
+ STRING (APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS} " )
261
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " ${COMMON_C_FLAGS} " )
262
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMMON_C_FLAGS} " )
263
+ # MariaDB uses -O3 for release builds.
264
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
265
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
242
266
ENDIF ()
243
267
IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
244
268
SET (COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int" )
245
- SET (CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS} " )
246
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS} " )
269
+ STRING (APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS} " )
270
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " ${COMMON_CXX_FLAGS} " )
271
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMMON_CXX_FLAGS} " )
272
+ # MariaDB uses -O3 for release builds.
273
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} " )
274
+ STRING (REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )
247
275
ENDIF ()
248
276
249
277
# Solaris flags
@@ -256,27 +284,33 @@ IF(UNIX)
256
284
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "i386" )
257
285
SET (COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic" )
258
286
SET (COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic" )
259
- SET ( CMAKE_C_FLAGS_DEBUG " -xO1 ${COMMON_C_FLAGS} " )
260
- SET ( CMAKE_CXX_FLAGS_DEBUG " -xO1 ${COMMON_CXX_FLAGS} " )
287
+ STRING ( APPEND CMAKE_C_FLAGS_DEBUG " -xO1 ${COMMON_C_FLAGS} " )
288
+ STRING ( APPEND CMAKE_CXX_FLAGS_DEBUG " -xO1 ${COMMON_CXX_FLAGS} " )
261
289
IF (32BIT )
262
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS} " )
263
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS} " )
290
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " -xO2 ${COMMON_C_FLAGS} " )
291
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " -xO2 ${COMMON_CXX_FLAGS} " )
292
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -xO2 ${COMMON_C_FLAGS} " )
293
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xO2 ${COMMON_CXX_FLAGS} " )
264
294
ELSEIF (64BIT )
265
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS} " )
266
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS} " )
295
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " -xO3 ${COMMON_C_FLAGS} " )
296
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " -xO3 ${COMMON_CXX_FLAGS} " )
297
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_C_FLAGS} " )
298
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_CXX_FLAGS} " )
267
299
ENDIF ()
268
- ELSE ()
300
+ ELSE ()
269
301
# Assume !x86 is SPARC
270
302
SET (COMMON_C_FLAGS "-g -Xa -xstrconst -mt" )
271
303
SET (COMMON_CXX_FLAGS "-g0 -noex -mt" )
272
304
IF (32BIT )
273
- SET (COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc" )
274
- SET (COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc" )
275
- ENDIF ()
276
- SET (CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS} " )
277
- SET (CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS} " )
278
- SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS} " )
279
- SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS} " )
305
+ STRING (APPEND COMMON_C_FLAGS " -xarch=sparc" )
306
+ STRING (APPEND COMMON_CXX_FLAGS " -xarch=sparc" )
307
+ ENDIF ()
308
+ STRING (APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS} " )
309
+ STRING (APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS} " )
310
+ STRING (APPEND CMAKE_C_FLAGS_RELEASE " -xO3 ${COMMON_C_FLAGS} " )
311
+ STRING (APPEND CMAKE_CXX_FLAGS_RELEASE " -xO3 ${COMMON_CXX_FLAGS} " )
312
+ STRING (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_C_FLAGS} " )
313
+ STRING (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_CXX_FLAGS} " )
280
314
ENDIF ()
281
315
ENDIF ()
282
316
ENDIF ()
0 commit comments