This commit is contained in:
Gary Preston 2016-02-18 13:55:37 +00:00
commit ad3115333d

View file

@ -56,33 +56,37 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
LIST(APPEND _FLAGS " -I\"${item}\"") LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH() ENDFOREACH()
# NOTE: As cmake files (eg FindQT4) may now use generator expressions around their defines that evaluate
# to an empty string, wrap all "items" in an expression that outputs a -D IFF the generated
# expression is not empty.
# Required for CMake 2.6 # Required for CMake 2.6
SET(GLOBAL_DEFINITIONS) SET(GLOBAL_DEFINITIONS)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
@ -106,14 +110,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
@ -135,10 +139,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
IF(_DEFINITIONS) IF(_DEFINITIONS)
FOREACH(item ${_DEFINITIONS}) FOREACH(item ${_DEFINITIONS})
# don't use dynamic expressions LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>")
IF(NOT item MATCHES "\\$<")
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDIF()
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
ENDIF() ENDIF()
@ -162,8 +163,6 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
ENDIF() ENDIF()
ENDIF() ENDIF()
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
IF(CMAKE_VERSION VERSION_LESS "3.3.0") IF(CMAKE_VERSION VERSION_LESS "3.3.0")
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
@ -180,6 +179,9 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
SEPARATE_ARGUMENTS(_FLAGS) SEPARATE_ARGUMENTS(_FLAGS)
ENDIF() ENDIF()
# Already in list form and items may contain non-leading spaces that should not be split on
LIST(INSERT _FLAGS 0 "${GLOBAL_DEFINITIONS}")
IF(CLANG) IF(CLANG)
# Determining all architectures and get common flags # Determining all architectures and get common flags
SET(_ARCH_NEXT) SET(_ARCH_NEXT)