• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Sets extra compile flags for a target, depending on the compiler being used.
2# Currently, only GCC is supported.
3MACRO(WEBKIT_SET_EXTRA_COMPILER_FLAGS _target)
4  IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
5    GET_TARGET_PROPERTY(OLD_COMPILE_FLAGS ${_target} COMPILE_FLAGS)
6    IF (${OLD_COMPILE_FLAGS} STREQUAL "OLD_COMPILE_FLAGS-NOTFOUND")
7        SET(OLD_COMPILE_FLAGS "")
8    ENDIF ()
9
10    # Disable some optimizations on buggy compiler versions
11    # GCC 4.5.1 does not implement -ftree-sra correctly
12    EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE COMPILER_VERSION)
13    IF (${COMPILER_VERSION} STREQUAL "4.5.1")
14        SET(OLD_COMPILE_FLAGS "${OLD_COMPILE_FLAGS} -fno-tree-sra")
15    ENDIF ()
16
17    IF (NOT SHARED_CORE)
18        SET(OLD_COMPILE_FLAGS "-fPIC -fvisibility=hidden ${OLD_COMPILE_FLAGS}")
19    ENDIF ()
20
21    SET(OLD_COMPILE_FLAGS "-fno-exceptions -fno-strict-aliasing ${OLD_COMPILE_FLAGS}")
22
23    # Enable warnings by default
24    SET(OLD_COMPILE_FLAGS "-W -DANOTHER_BRICK_IN_THE -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat -Wformat-security -Wmissing-format-attribute -Wno-format-y2k -Wno-parentheses -Wno-unused-parameter -Wpointer-arith  -Wreturn-type -Wundef -Wwrite-strings ${OLD_COMPILE_FLAGS}")
25
26    SET_TARGET_PROPERTIES (${_target} PROPERTIES
27	COMPILE_FLAGS "${OLD_COMPILE_FLAGS}")
28
29    UNSET(OLD_COMPILE_FLAGS)
30  ENDIF ()
31ENDMACRO()
32
33
34# Append the given flag to the target property.
35# Builds on top of GET_TARGET_PROPERTY() and SET_TARGET_PROPERTIES()
36MACRO (ADD_TARGET_PROPERTIES _target _property _flags)
37  GET_TARGET_PROPERTY (_tmp ${_target} ${_property})
38  IF (NOT _tmp)
39    SET (_tmp "")
40  ENDIF (NOT _tmp)
41
42  FOREACH (f ${_flags})
43    SET (_tmp "${_tmp} ${f}")
44  ENDFOREACH (f ${_flags})
45
46  SET_TARGET_PROPERTIES (${_target} PROPERTIES ${_property} ${_tmp})
47  UNSET (_tmp)
48ENDMACRO (ADD_TARGET_PROPERTIES _target _property _flags)
49
50
51# Append the given dependencies to the source file
52MACRO(ADD_SOURCE_DEPENDENCIES _source _deps)
53  GET_SOURCE_FILE_PROPERTY(_tmp ${_source} OBJECT_DEPENDS)
54  IF (NOT _tmp)
55    SET (_tmp "")
56  ENDIF ()
57
58  FOREACH (f ${_deps})
59    LIST(APPEND _tmp "${f}")
60  ENDFOREACH ()
61
62  SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES OBJECT_DEPENDS "${_tmp}")
63  UNSET(_tmp)
64ENDMACRO()
65
66
67# Append the given dependencies to the source file
68# This one consider the given dependencies are in ${DERIVED_SOURCES_WEBCORE_DIR}
69# and prepends this to every member of dependencies list
70MACRO(ADD_SOURCE_WEBCORE_DERIVED_DEPENDENCIES _source _deps)
71  SET(_tmp "")
72  FOREACH (f ${_deps})
73    LIST(APPEND _tmp "${DERIVED_SOURCES_WEBCORE_DIR}/${f}")
74  ENDFOREACH ()
75
76  ADD_SOURCE_DEPENDENCIES(${_source} ${_tmp})
77  UNSET(_tmp)
78ENDMACRO()
79
80