fix for building with msvc/cmake take 2 (think its correct this time)
[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
197         if(WIN32 AND NOT UNIX)
198                 link_directories(${PTHREADS_LIBPATH})
199         endif()
200 endmacro()
201
202 macro(setup_liblinks
203         target)
204         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ")
205
206         target_link_libraries(${target}
207                         ${OPENGL_gl_LIBRARY}
208                         ${OPENGL_glu_LIBRARY}
209                         ${JPEG_LIBRARIES}
210                         ${PNG_LIBRARIES}
211                         ${ZLIB_LIBRARIES}
212                         ${LLIBS})
213
214         # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
215         if(WITH_PYTHON)  # AND NOT WITH_PYTHON_MODULE  # WIN32 needs
216                 target_link_libraries(${target} ${PYTHON_LINKFLAGS})
217
218                 if(WIN32 AND NOT UNIX)
219                         file_list_suffix(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d")
220                         target_link_libraries_debug(${target} "${PYTHON_LIBRARIES_DEBUG}")
221                         target_link_libraries_optimized(${target} "${PYTHON_LIBRARIES}")
222                         unset(PYTHON_LIBRARIES_DEBUG)
223                 else()
224                         target_link_libraries(${target} ${PYTHON_LIBRARIES})
225                 endif()
226         endif()
227
228         if(NOT WITH_BUILTIN_GLEW)
229                 target_link_libraries(${target} ${GLEW_LIBRARY})
230         endif()
231
232         target_link_libraries(${target}
233                         ${OPENGL_glu_LIBRARY}
234                         ${JPEG_LIBRARIES}
235                         ${PNG_LIBRARIES}
236                         ${ZLIB_LIBRARIES}
237                         ${FREETYPE_LIBRARY})
238
239         if(WITH_INTERNATIONAL)
240                 target_link_libraries(${target} ${GETTEXT_LIB})
241
242                 if(WIN32 AND NOT UNIX)
243                         target_link_libraries(${target} ${ICONV_LIBRARIES})
244                 endif()
245         endif()
246
247         if(WITH_OPENAL)
248                 target_link_libraries(${target} ${OPENAL_LIBRARY})
249         endif()
250         if(WITH_FFTW3)
251                 target_link_libraries(${target} ${FFTW3_LIBRARIES})
252         endif()
253         if(WITH_JACK)
254                 target_link_libraries(${target} ${JACK_LIBRARIES})
255         endif()
256         if(WITH_CODEC_SNDFILE)
257                 target_link_libraries(${target} ${SNDFILE_LIBRARIES})
258         endif()
259         if(WITH_SAMPLERATE)
260                 target_link_libraries(${target} ${SAMPLERATE_LIBRARIES})
261         endif()
262         if(WITH_SDL)
263                 target_link_libraries(${target} ${SDL_LIBRARY})
264         endif()
265         if(WITH_CODEC_QUICKTIME)
266                 target_link_libraries(${target} ${QUICKTIME_LIBRARIES})
267         endif()
268         if(WITH_IMAGE_TIFF)
269                 target_link_libraries(${target} ${TIFF_LIBRARY})
270         endif()
271         if(WITH_IMAGE_OPENEXR)
272                 if(WIN32 AND NOT UNIX)
273                         file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
274                         target_link_libraries_debug(${target} "${OPENEXR_LIBRARIES_DEBUG}")
275                         target_link_libraries_optimized(${target} "${OPENEXR_LIBRARIES}")
276                         unset(OPENEXR_LIBRARIES_DEBUG)
277                 else()
278                         target_link_libraries(${target} ${OPENEXR_LIBRARIES})
279                 endif()
280         endif()
281         if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
282                 target_link_libraries(${target} ${OPENJPEG_LIBRARIES})
283         endif()
284         if(WITH_CODEC_FFMPEG)
285                 target_link_libraries(${target} ${FFMPEG_LIBRARIES})
286         endif()
287         if(WITH_OPENCOLLADA)
288                 if(WIN32 AND NOT UNIX)
289                         file_list_suffix(OPENCOLLADA_LIBRARIES_DEBUG "${OPENCOLLADA_LIBRARIES}" "_d")
290                         target_link_libraries_debug(${target} "${OPENCOLLADA_LIBRARIES_DEBUG}")
291                         target_link_libraries_optimized(${target} "${OPENCOLLADA_LIBRARIES}")
292                         unset(OPENCOLLADA_LIBRARIES_DEBUG)
293
294                         file_list_suffix(PCRE_LIB_DEBUG "${PCRE_LIB}" "_d")
295                         target_link_libraries_debug(${target} "${PCRE_LIB_DEBUG}")
296                         target_link_libraries_optimized(${target} "${PCRE_LIB}")
297                         unset(PCRE_LIB_DEBUG)
298
299                         if(EXPAT_LIB)
300                                 file_list_suffix(EXPAT_LIB_DEBUG "${EXPAT_LIB}" "_d")
301                                 target_link_libraries_debug(${target} "${EXPAT_LIB_DEBUG}")
302                                 target_link_libraries_optimized(${target} "${EXPAT_LIB}")
303                                 unset(EXPAT_LIB_DEBUG)
304                         endif()
305                 else()
306                         target_link_libraries(${target}
307                                         ${OPENCOLLADA_LIBRARIES}
308                                         ${PCRE_LIB}
309                                         ${EXPAT_LIB})
310                 endif()
311         endif()
312         if(WITH_MEM_JEMALLOC)
313                 target_link_libraries(${target} ${JEMALLOC_LIBRARIES})
314         endif()
315         if(WIN32 AND NOT UNIX)
316                 target_link_libraries(${target} ${PTHREADS_LIBRARIES})
317         endif()
318 endmacro()
319
320 macro(TEST_SSE_SUPPORT)
321         include(CheckCSourceRuns)
322
323         # message(STATUS "Detecting SSE support")
324         if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
325                 set(CMAKE_REQUIRED_FLAGS "-msse -msse2")
326         elseif(MSVC)
327                 set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") # TODO, SSE 1 ?
328         endif()
329
330         if(NOT DEFINED ${SUPPORT_SSE_BUILD})
331                 check_c_source_runs("
332                         #include <xmmintrin.h>
333                         int main() { __m128 v = _mm_setzero_ps(); return 0; }"
334                 SUPPORT_SSE_BUILD)
335                 
336                 if(SUPPORT_SSE_BUILD)
337                         message(STATUS "SSE Support: detected.")
338                 else()
339                         message(STATUS "SSE Support: missing.")
340                 endif()
341                 set(${SUPPORT_SSE_BUILD} ${SUPPORT_SSE_BUILD} CACHE INTERNAL "SSE Test")
342         endif() 
343
344         if(NOT DEFINED ${SUPPORT_SSE2_BUILD})
345                 check_c_source_runs("
346                         #include <emmintrin.h>
347                         int main() { __m128d v = _mm_setzero_pd(); return 0; }"
348                 SUPPORT_SSE2_BUILD)
349
350                 if(SUPPORT_SSE2_BUILD)
351                         message(STATUS "SSE2 Support: detected.")
352                 else()
353                         message(STATUS "SSE2 Support: missing.")
354                 endif() 
355                 set(${SUPPORT_SSE2_BUILD} ${SUPPORT_SSE2_BUILD} CACHE INTERNAL "SSE2 Test")
356         endif()
357
358 endmacro()
359
360 # when we have warnings as errors applied globally this
361 # needs to be removed for some external libs which we dont maintain.
362
363 # utility macro
364 macro(remove_flag
365         flag)
366
367         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
368         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
369         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
370         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
371         string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
372
373         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
374         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
375         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
376         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
377         string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
378
379 endmacro()
380
381 macro(remove_strict_flags)
382
383         if(CMAKE_COMPILER_IS_GNUCC)
384                 remove_flag("-Wstrict-prototypes")
385                 remove_flag("-Wunused-parameter")
386                 remove_flag("-Wwrite-strings")
387                 remove_flag("-Wshadow")
388                 remove_flag("-Werror=[^ ]+")
389                 remove_flag("-Werror")
390         endif()
391
392         if(MSVC)
393                 # TODO
394         endif()
395
396 endmacro()
397
398 macro(ADD_CHECK_C_COMPILER_FLAG
399         _CFLAGS
400         _CACHE_VAR
401         _FLAG)
402
403         include(CheckCCompilerFlag)
404
405         CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
406         if(${_CACHE_VAR})
407                 # message(STATUS "Using CFLAG: ${_FLAG}")
408                 set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}")
409         else()
410                 message(STATUS "Unsupported CFLAG: ${_FLAG}")
411         endif()
412 endmacro()
413
414 macro(ADD_CHECK_CXX_COMPILER_FLAG
415         _CXXFLAGS
416         _CACHE_VAR
417         _FLAG)
418
419         include(CheckCXXCompilerFlag)
420
421         CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
422         if(${_CACHE_VAR})
423                 # message(STATUS "Using CXXFLAG: ${_FLAG}")
424                 set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}")
425         else()
426                 message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
427         endif()
428 endmacro()
429
430 macro(get_blender_version)
431         # So cmake depends on BKE_blender.h, beware of inf-loops!
432         CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h ${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender.h.done)
433
434         file(STRINGS ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h _contents REGEX "^#define[ \t]+BLENDER_.*$")
435
436         string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION[ \t]+([0-9]+).*" "\\1" _out_version "${_contents}")
437         string(REGEX REPLACE ".*#define[ \t]+BLENDER_SUBVERSION[ \t]+([0-9]+).*" "\\1" _out_subversion "${_contents}")
438         string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION_CHAR[ \t]+([a-z]+).*" "\\1" _out_version_char "${_contents}")
439         string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION_CYCLE[ \t]+([a-z]+).*" "\\1" _out_version_cycle "${_contents}")
440
441         if(NOT ${_out_version} MATCHES "[0-9]+")
442                 message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION")
443         endif()
444
445         if(NOT ${_out_subversion} MATCHES "[0-9]+")
446                 message(FATAL_ERROR "Version parsing failed for BLENDER_SUBVERSION")
447         endif()
448
449         # clumsy regex, only single char are ok but it could be unset
450
451         string(LENGTH "${_out_version_char}" _out_version_char_len)
452         if(NOT _out_version_char_len EQUAL 1)
453                 set(_out_version_char "")
454         elseif(NOT ${_out_version_char} MATCHES "[a-z]+")
455                 message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CHAR")
456         endif()
457
458         if(NOT ${_out_version_cycle} MATCHES "[a-z]+")
459                 message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CYCLE")
460         endif()
461
462         math(EXPR BLENDER_VERSION_MAJOR "${_out_version} / 100")
463         math(EXPR BLENDER_VERSION_MINOR "${_out_version} % 100")
464         set(BLENDER_VERSION "${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}")
465
466         set(BLENDER_SUBVERSION ${_out_subversion})
467         set(BLENDER_VERSION_CHAR ${_out_version_char})
468         set(BLENDER_VERSION_CYCLE ${_out_version_cycle})
469
470         # for packaging, alpha to numbers
471         string(COMPARE EQUAL "${BLENDER_VERSION_CHAR}" "" _out_version_char_empty)
472         if(${_out_version_char_empty})
473                 set(BLENDER_VERSION_CHAR_INDEX "0")
474         else()
475                 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)
476                 list(FIND _char_ls ${BLENDER_VERSION_CHAR} _out_version_char_index)
477                 math(EXPR BLENDER_VERSION_CHAR_INDEX "${_out_version_char_index} + 1")
478                 unset(_char_ls)
479                 unset(_out_version_char_index)
480         endif()
481
482         unset(_out_subversion)
483         unset(_out_version_char)
484         unset(_out_version_char_empty)
485         unset(_out_version_cycle)
486
487         # message(STATUS "Version (Internal): ${BLENDER_VERSION}.${BLENDER_SUBVERSION}, Version (external): ${BLENDER_VERSION}${BLENDER_VERSION_CHAR}-${BLENDER_VERSION_CYCLE}")
488 endmacro()
489
490
491 # hacks to override initial project settings
492 # these macros must be called directly before/after project(Blender) 
493 macro(blender_project_hack_pre)
494         # ----------------
495         # MINGW HACK START
496         # ignore system set flag, use our own
497         # must be before project(...)
498         # if the user wants to add their own its ok after first run.
499         if(DEFINED CMAKE_C_STANDARD_LIBRARIES)
500                 set(_reset_standard_libraries OFF)
501         else()
502                 set(_reset_standard_libraries ON)
503         endif()
504
505         # ------------------
506         # GCC -O3 HACK START
507         # needed because O3 can cause problems but
508         # allow the builder to set O3 manually after.
509         if(DEFINED CMAKE_C_FLAGS_RELEASE)
510                 set(_reset_standard_cflags_rel OFF)
511         else()
512                 set(_reset_standard_cflags_rel ON)
513         endif()
514         if(DEFINED CMAKE_CXX_FLAGS_RELEASE)
515                 set(_reset_standard_cxxflags_rel OFF)
516         else()
517                 set(_reset_standard_cxxflags_rel ON)
518         endif()
519 endmacro()
520
521
522 macro(blender_project_hack_post)
523         # --------------
524         # MINGW HACK END
525         if (_reset_standard_libraries)
526                 # Must come after project(...)
527                 #
528                 # MINGW workaround for -ladvapi32 being included which surprisingly causes
529                 # string formatting of floats, eg: printf("%.*f", 3, value). to crash blender
530                 # with a meaningless stack trace. by overriding this flag we ensure we only
531                 # have libs we define and that cmake & scons builds match.
532                 set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
533                 set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
534                 mark_as_advanced(CMAKE_C_STANDARD_LIBRARIES)
535                 mark_as_advanced(CMAKE_CXX_STANDARD_LIBRARIES)
536         endif()
537         unset(_reset_standard_libraries)
538
539
540         # ----------------
541         # GCC -O3 HACK END
542         if(_reset_standard_cflags_rel)
543                 string(REGEX REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
544                 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)
545                 mark_as_advanced(CMAKE_C_FLAGS_RELEASE)
546         endif()
547
548         if(_reset_standard_cxxflags_rel)
549                 string(REGEX REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
550                 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
551                 mark_as_advanced(CMAKE_CXX_FLAGS_RELEASE)
552         endif()
553
554         unset(_reset_standard_cflags_rel)
555         unset(_reset_standard_cxxflags_rel)
556
557         # ------------------------------------------------------------------
558         # workaround for omission in cmake 2.8.4's GNU.cmake, fixed in 2.8.5
559         if(CMAKE_COMPILER_IS_GNUCC)
560                 if(NOT DARWIN)
561                         set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
562                 endif()
563         endif()
564
565 endmacro()