NDOF related edits
[blender.git] / build_files / cmake / macros.cmake
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # $Id$
3
4
5 # foo_bar.spam --> foo_barMySuffix.spam
6 macro(file_suffix
7         file_name_new file_name file_suffix
8         )
9
10         get_filename_component(_file_name_PATH ${file_name} PATH)
11         get_filename_component(_file_name_NAME_WE ${file_name} NAME_WE)
12         get_filename_component(_file_name_EXT ${file_name} EXT)
13         set(${file_name_new} "${_file_name_PATH}/${_file_name_NAME_WE}${file_suffix}${_file_name_EXT}")
14
15         unset(_file_name_PATH)
16         unset(_file_name_NAME_WE)
17         unset(_file_name_EXT)
18 endmacro()
19
20 # usefil for adding debug suffix to library lists:
21 # /somepath/foo.lib --> /somepath/foo_d.lib
22 macro(file_list_suffix
23         fp_list_new fp_list fn_suffix
24         )
25
26         # incase of empty list
27         set(_fp)
28         set(_fp_suffixed)
29
30         set(fp_list_new)
31
32         foreach(_fp ${fp_list})
33                 file_suffix(_fp_suffixed "${_fp}" "${fn_suffix}")
34                 list(APPEND "${fp_list_new}" "${_fp_suffixed}")
35         endforeach()
36
37         unset(_fp)
38         unset(_fp_suffixed)
39
40 endmacro()
41
42
43 macro(target_link_libraries_optimized TARGET LIBS)
44         foreach(_LIB ${LIBS})
45                 target_link_libraries(${TARGET} optimized "${_LIB}")
46         endforeach()
47         unset(_LIB)
48 endmacro()
49
50 macro(target_link_libraries_debug TARGET LIBS)
51         foreach(_LIB ${LIBS})
52                 target_link_libraries(${TARGET} debug "${_LIB}")
53         endforeach()
54         unset(_LIB)
55 endmacro()
56
57 # Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
58 # use it instead of include_directories()
59 macro(blender_include_dirs
60         includes)
61         set(_ALL_INCS "")
62         foreach(_INC ${ARGV})
63                 get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
64                 list(APPEND _ALL_INCS ${_ABS_INC})
65         endforeach()
66         include_directories(${_ALL_INCS})
67         unset(_INC)
68         unset(_ABS_INC)
69         unset(_ALL_INCS)
70 endmacro()
71
72 macro(blender_include_dirs_sys
73         includes)
74         set(_ALL_INCS "")
75         foreach(_INC ${ARGV})
76                 get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
77                 list(APPEND _ALL_INCS ${_ABS_INC})
78         endforeach()
79         include_directories(SYSTEM ${_ALL_INCS})
80         unset(_INC)
81         unset(_ABS_INC)
82         unset(_ALL_INCS)
83 endmacro()
84
85 macro(blender_source_group
86         sources)
87
88         # Group by location on disk
89         source_group("Source Files" FILES CMakeLists.txt)
90
91         foreach(_SRC ${sources})
92                 get_filename_component(_SRC_EXT ${_SRC} EXT)
93                 if((${_SRC_EXT} MATCHES ".h") OR (${_SRC_EXT} MATCHES ".hpp"))
94                         source_group("Header Files" FILES ${_SRC})
95                 else()
96                         source_group("Source Files" FILES ${_SRC})
97                 endif()
98         endforeach()
99
100         unset(_SRC)
101         unset(_SRC_EXT)
102 endmacro()
103
104
105 # only MSVC uses SOURCE_GROUP
106 macro(blender_add_lib_nolist
107         name
108         sources
109         includes
110         includes_sys)
111
112         # message(STATUS "Configuring library ${name}")
113
114         # include_directories(${includes})
115         # include_directories(SYSTEM ${includes_sys})
116         blender_include_dirs("${includes}")
117         blender_include_dirs_sys("${includes_sys}")
118
119         add_library(${name} ${sources})
120
121         # works fine without having the includes
122         # listed is helpful for IDE's (QtCreator/MSVC)
123         blender_source_group("${sources}")
124
125 endmacro()
126
127
128 macro(blender_add_lib
129         name
130         sources
131         includes
132         includes_sys)
133
134         blender_add_lib_nolist(${name} "${sources}" "${includes}" "${includes_sys}")
135
136         set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
137 endmacro()
138
139
140 macro(SETUP_LIBDIRS)
141         # see "cmake --help-policy CMP0003"
142         if(COMMAND cmake_policy)
143                 cmake_policy(SET CMP0003 NEW)
144         endif()
145
146         link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
147
148         if(WITH_PYTHON)  #  AND NOT WITH_PYTHON_MODULE  # WIN32 needs
149                 link_directories(${PYTHON_LIBPATH})
150         endif()
151         if(WITH_INTERNATIONAL)
152                 link_directories(${ICONV_LIBPATH})
153                 link_directories(${GETTEXT_LIBPATH})
154         endif()
155         if(WITH_SDL)
156                 link_directories(${SDL_LIBPATH})
157         endif()
158         if(WITH_CODEC_FFMPEG)
159                 link_directories(${FFMPEG_LIBPATH})
160         endif()
161         if(WITH_IMAGE_OPENEXR)
162                 link_directories(${OPENEXR_LIBPATH})
163         endif()
164         if(WITH_IMAGE_TIFF)
165                 link_directories(${TIFF_LIBPATH})
166         endif()
167         if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
168                 link_directories(${OPENJPEG_LIBPATH})
169         endif()
170         if(WITH_CODEC_QUICKTIME)
171                 link_directories(${QUICKTIME_LIBPATH})
172         endif()
173         if(WITH_OPENAL)
174                 link_directories(${OPENAL_LIBPATH})
175         endif()
176         if(WITH_JACK)
177                 link_directories(${JACK_LIBPATH})
178         endif()
179         if(WITH_CODEC_SNDFILE)
180                 link_directories(${SNDFILE_LIBPATH})
181         endif()
182         if(WITH_SAMPLERATE)
183                 link_directories(${SAMPLERATE_LIBPATH})
184         endif()
185         if(WITH_FFTW3)
186                 link_directories(${FFTW3_LIBPATH})
187         endif()
188         if(WITH_OPENCOLLADA)
189                 link_directories(${OPENCOLLADA_LIBPATH})
190                 link_directories(${PCRE_LIBPATH})
191                 link_directories(${EXPAT_LIBPATH})
192         endif()
193         if(WITH_MEM_JEMALLOC)
194                 link_directories(${JEMALLOC_LIBPATH})
195         endif()
196         if(WITH_INPUT_NDOF)
197                 link_directories(${NDOF_LIBPATH})
198         endif()
199
200         if(WIN32 AND NOT UNIX)
201                 link_directories(${PTHREADS_LIBPATH})
202         endif()
203 endmacro()
204
205 macro(setup_liblinks
206         target)
207
208         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
209         set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
210
211         target_link_libraries(${target}
212                         ${OPENGL_gl_LIBRARY}
213                         ${OPENGL_glu_LIBRARY}
214                         ${JPEG_LIBRARIES}
215                         ${PNG_LIBRARIES}
216                         ${ZLIB_LIBRARIES}
217                         ${PLATFORM_LINKLIBS})
218
219         # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
220         if(WITH_PYTHON)  # AND NOT WITH_PYTHON_MODULE  # WIN32 needs
221                 target_link_libraries(${target} ${PYTHON_LINKFLAGS})
222
223                 if(WIN32 AND NOT UNIX)
224                         file_list_suffix(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d")
225                         target_link_libraries_debug(${target} "${PYTHON_LIBRARIES_DEBUG}")
226                         target_link_libraries_optimized(${target} "${PYTHON_LIBRARIES}")
227                         unset(PYTHON_LIBRARIES_DEBUG)
228                 else()
229                         target_link_libraries(${target} ${PYTHON_LIBRARIES})
230                 endif()
231         endif()
232
233         if(NOT WITH_BUILTIN_GLEW)
234                 target_link_libraries(${target} ${GLEW_LIBRARY})
235         endif()
236
237         target_link_libraries(${target}
238                         ${OPENGL_glu_LIBRARY}
239                         ${JPEG_LIBRARIES}
240                         ${PNG_LIBRARIES}
241                         ${ZLIB_LIBRARIES}
242                         ${FREETYPE_LIBRARY})
243
244         if(WITH_INTERNATIONAL)
245                 target_link_libraries(${target} ${GETTEXT_LIB})
246
247                 if(WIN32 AND NOT UNIX)
248                         target_link_libraries(${target} ${ICONV_LIBRARIES})
249                 endif()
250         endif()
251
252         if(WITH_OPENAL)
253                 target_link_libraries(${target} ${OPENAL_LIBRARY})
254         endif()
255         if(WITH_FFTW3)
256                 target_link_libraries(${target} ${FFTW3_LIBRARIES})
257         endif()
258         if(WITH_JACK)
259                 target_link_libraries(${target} ${JACK_LIBRARIES})
260         endif()
261         if(WITH_CODEC_SNDFILE)
262                 target_link_libraries(${target} ${SNDFILE_LIBRARIES})
263         endif()
264         if(WITH_SAMPLERATE)
265                 target_link_libraries(${target} ${SAMPLERATE_LIBRARIES})
266         endif()
267         if(WITH_SDL)
268                 target_link_libraries(${target} ${SDL_LIBRARY})
269         endif()
270         if(WITH_CODEC_QUICKTIME)
271                 target_link_libraries(${target} ${QUICKTIME_LIBRARIES})
272         endif()
273         if(WITH_IMAGE_TIFF)
274                 target_link_libraries(${target} ${TIFF_LIBRARY})
275         endif()
276         if(WITH_IMAGE_OPENEXR)
277                 if(WIN32 AND NOT UNIX)
278                         file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
279                         target_link_libraries_debug(${target} "${OPENEXR_LIBRARIES_DEBUG}")
280                         target_link_libraries_optimized(${target} "${OPENEXR_LIBRARIES}")
281                         unset(OPENEXR_LIBRARIES_DEBUG)
282                 else()
283                         target_link_libraries(${target} ${OPENEXR_LIBRARIES})
284                 endif()
285         endif()
286         if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
287                 target_link_libraries(${target} ${OPENJPEG_LIBRARIES})
288         endif()
289         if(WITH_CODEC_FFMPEG)
290                 target_link_libraries(${target} ${FFMPEG_LIBRARIES})
291         endif()
292         if(WITH_OPENCOLLADA)
293                 if(WIN32 AND NOT UNIX)
294                         file_list_suffix(OPENCOLLADA_LIBRARIES_DEBUG "${OPENCOLLADA_LIBRARIES}" "_d")
295                         target_link_libraries_debug(${target} "${OPENCOLLADA_LIBRARIES_DEBUG}")
296                         target_link_libraries_optimized(${target} "${OPENCOLLADA_LIBRARIES}")
297                         unset(OPENCOLLADA_LIBRARIES_DEBUG)
298
299                         file_list_suffix(PCRE_LIB_DEBUG "${PCRE_LIB}" "_d")
300                         target_link_libraries_debug(${target} "${PCRE_LIB_DEBUG}")
301                         target_link_libraries_optimized(${target} "${PCRE_LIB}")
302                         unset(PCRE_LIB_DEBUG)
303
304                         if(EXPAT_LIB)
305                                 file_list_suffix(EXPAT_LIB_DEBUG "${EXPAT_LIB}" "_d")
306                                 target_link_libraries_debug(${target} "${EXPAT_LIB_DEBUG}")
307                                 target_link_libraries_optimized(${target} "${EXPAT_LIB}")
308                                 unset(EXPAT_LIB_DEBUG)
309                         endif()
310                 else()
311                         target_link_libraries(${target}
312                                         ${OPENCOLLADA_LIBRARIES}
313                                         ${PCRE_LIB}
314                                         ${EXPAT_LIB})
315                 endif()
316         endif()
317         if(WITH_MEM_JEMALLOC)
318                 target_link_libraries(${target} ${JEMALLOC_LIBRARIES})
319         endif()
320         if(WITH_INPUT_NDOF)
321                 target_link_libraries(${target} ${NDOF_LIBRARY})
322         endif()
323
324         if(WIN32 AND NOT UNIX)
325                 target_link_libraries(${target} ${PTHREADS_LIBRARIES})
326         endif()
327 endmacro()
328
329 macro(TEST_SSE_SUPPORT)
330         include(CheckCSourceRuns)
331
332         # message(STATUS "Detecting SSE support")
333         if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
334                 set(CMAKE_REQUIRED_FLAGS "-msse -msse2")
335         elseif(MSVC)
336                 set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") # TODO, SSE 1 ?
337         endif()
338
339         if(NOT DEFINED ${SUPPORT_SSE_BUILD})
340                 check_c_source_runs("
341                         #include <xmmintrin.h>
342                         int main() { __m128 v = _mm_setzero_ps(); return 0; }"
343                 SUPPORT_SSE_BUILD)
344                 
345                 if(SUPPORT_SSE_BUILD)
346                         message(STATUS "SSE Support: detected.")
347                 else()
348                         message(STATUS "SSE Support: missing.")
349                 endif()
350                 set(${SUPPORT_SSE_BUILD} ${SUPPORT_SSE_BUILD} CACHE INTERNAL "SSE Test")
351         endif() 
352
353         if(NOT DEFINED ${SUPPORT_SSE2_BUILD})
354                 check_c_source_runs("
355                         #include <emmintrin.h>
356                         int main() { __m128d v = _mm_setzero_pd(); return 0; }"
357                 SUPPORT_SSE2_BUILD)
358
359                 if(SUPPORT_SSE2_BUILD)
360                         message(STATUS "SSE2 Support: detected.")
361                 else()
362                         message(STATUS "SSE2 Support: missing.")
363                 endif() 
364                 set(${SUPPORT_SSE2_BUILD} ${SUPPORT_SSE2_BUILD} CACHE INTERNAL "SSE2 Test")
365         endif()
366
367 endmacro()
368
369 # when we have warnings as errors applied globally this
370 # needs to be removed for some external libs which we dont maintain.
371
372 # utility macro
373 macro(remove_flag
374         flag)
375
376         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
377         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
378         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
379         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
380         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
381
382         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
383         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
384         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
385         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
386         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
387
388 endmacro()
389
390 macro(remove_strict_flags)
391
392         if(CMAKE_COMPILER_IS_GNUCC)
393                 remove_flag("-Wstrict-prototypes")
394                 remove_flag("-Wunused-parameter")
395                 remove_flag("-Wwrite-strings")
396                 remove_flag("-Wshadow")
397                 remove_flag("-Werror=[^ ]+")
398                 remove_flag("-Werror")
399         endif()
400
401         if(MSVC)
402                 # TODO
403         endif()
404
405 endmacro()
406
407 macro(ADD_CHECK_C_COMPILER_FLAG
408         _CFLAGS
409         _CACHE_VAR
410         _FLAG)
411
412         include(CheckCCompilerFlag)
413
414         CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
415         if(${_CACHE_VAR})
416                 # message(STATUS "Using CFLAG: ${_FLAG}")
417                 set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}")
418         else()
419                 message(STATUS "Unsupported CFLAG: ${_FLAG}")
420         endif()
421 endmacro()
422
423 macro(ADD_CHECK_CXX_COMPILER_FLAG
424         _CXXFLAGS
425         _CACHE_VAR
426         _FLAG)
427
428         include(CheckCXXCompilerFlag)
429
430         CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
431         if(${_CACHE_VAR})
432                 # message(STATUS "Using CXXFLAG: ${_FLAG}")
433                 set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}")
434         else()
435                 message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
436         endif()
437 endmacro()
438
439 macro(get_blender_version)
440         # So cmake depends on BKE_blender.h, beware of inf-loops!
441         CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h ${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender.h.done)
442
443         file(STRINGS ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h _contents REGEX "^#define[ \t]+BLENDER_.*$")
444
445         string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION[ \t]+([0-9]+).*" "\\1" _out_version "${_contents}")
446         string(REGEX REPLACE ".*#define[ \t]+BLENDER_SUBVERSION[ \t]+([0-9]+).*" "\\1" _out_subversion "${_contents}")
447         string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION_CHAR[ \t]+([a-z]+).*" "\\1" _out_version_char "${_contents}")
448         string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION_CYCLE[ \t]+([a-z]+).*" "\\1" _out_version_cycle "${_contents}")
449
450         if(NOT ${_out_version} MATCHES "[0-9]+")
451                 message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION")
452         endif()
453
454         if(NOT ${_out_subversion} MATCHES "[0-9]+")
455                 message(FATAL_ERROR "Version parsing failed for BLENDER_SUBVERSION")
456         endif()
457
458         # clumsy regex, only single char are ok but it could be unset
459
460         string(LENGTH "${_out_version_char}" _out_version_char_len)
461         if(NOT _out_version_char_len EQUAL 1)
462                 set(_out_version_char "")
463         elseif(NOT ${_out_version_char} MATCHES "[a-z]+")
464                 message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CHAR")
465         endif()
466
467         if(NOT ${_out_version_cycle} MATCHES "[a-z]+")
468                 message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CYCLE")
469         endif()
470
471         math(EXPR BLENDER_VERSION_MAJOR "${_out_version} / 100")
472         math(EXPR BLENDER_VERSION_MINOR "${_out_version} % 100")
473         set(BLENDER_VERSION "${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}")
474
475         set(BLENDER_SUBVERSION ${_out_subversion})
476         set(BLENDER_VERSION_CHAR ${_out_version_char})
477         set(BLENDER_VERSION_CYCLE ${_out_version_cycle})
478
479         # for packaging, alpha to numbers
480         string(COMPARE EQUAL "${BLENDER_VERSION_CHAR}" "" _out_version_char_empty)
481         if(${_out_version_char_empty})
482                 set(BLENDER_VERSION_CHAR_INDEX "0")
483         else()
484                 set(_char_ls a b c d e f g h i j k l m n o p q r s t u v w q y z)
485                 list(FIND _char_ls ${BLENDER_VERSION_CHAR} _out_version_char_index)
486                 math(EXPR BLENDER_VERSION_CHAR_INDEX "${_out_version_char_index} + 1")
487                 unset(_char_ls)
488                 unset(_out_version_char_index)
489         endif()
490
491         unset(_out_subversion)
492         unset(_out_version_char)
493         unset(_out_version_char_empty)
494         unset(_out_version_cycle)
495
496         # message(STATUS "Version (Internal): ${BLENDER_VERSION}.${BLENDER_SUBVERSION}, Version (external): ${BLENDER_VERSION}${BLENDER_VERSION_CHAR}-${BLENDER_VERSION_CYCLE}")
497 endmacro()
498
499
500 # hacks to override initial project settings
501 # these macros must be called directly before/after project(Blender) 
502 macro(blender_project_hack_pre)
503         # ----------------
504         # MINGW HACK START
505         # ignore system set flag, use our own
506         # must be before project(...)
507         # if the user wants to add their own its ok after first run.
508         if(DEFINED CMAKE_C_STANDARD_LIBRARIES)
509                 set(_reset_standard_libraries OFF)
510         else()
511                 set(_reset_standard_libraries ON)
512         endif()
513
514         # ------------------
515         # GCC -O3 HACK START
516         # needed because O3 can cause problems but
517         # allow the builder to set O3 manually after.
518         if(DEFINED CMAKE_C_FLAGS_RELEASE)
519                 set(_reset_standard_cflags_rel OFF)
520         else()
521                 set(_reset_standard_cflags_rel ON)
522         endif()
523         if(DEFINED CMAKE_CXX_FLAGS_RELEASE)
524                 set(_reset_standard_cxxflags_rel OFF)
525         else()
526                 set(_reset_standard_cxxflags_rel ON)
527         endif()
528 endmacro()
529
530
531 macro(blender_project_hack_post)
532         # --------------
533         # MINGW HACK END
534         if (_reset_standard_libraries)
535                 # Must come after project(...)
536                 #
537                 # MINGW workaround for -ladvapi32 being included which surprisingly causes
538                 # string formatting of floats, eg: printf("%.*f", 3, value). to crash blender
539                 # with a meaningless stack trace. by overriding this flag we ensure we only
540                 # have libs we define and that cmake & scons builds match.
541                 set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
542                 set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
543                 mark_as_advanced(CMAKE_C_STANDARD_LIBRARIES)
544                 mark_as_advanced(CMAKE_CXX_STANDARD_LIBRARIES)
545         endif()
546         unset(_reset_standard_libraries)
547
548
549         # ----------------
550         # GCC -O3 HACK END
551         if(_reset_standard_cflags_rel)
552                 string(REGEX REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
553                 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)
554                 mark_as_advanced(CMAKE_C_FLAGS_RELEASE)
555         endif()
556
557         if(_reset_standard_cxxflags_rel)
558                 string(REGEX REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
559                 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
560                 mark_as_advanced(CMAKE_CXX_FLAGS_RELEASE)
561         endif()
562
563         unset(_reset_standard_cflags_rel)
564         unset(_reset_standard_cxxflags_rel)
565
566         # ------------------------------------------------------------------
567         # workaround for omission in cmake 2.8.4's GNU.cmake, fixed in 2.8.5
568         if(CMAKE_COMPILER_IS_GNUCC)
569                 if(NOT DARWIN)
570                         set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
571                 endif()
572         endif()
573
574 endmacro()