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