mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Ensure definitions from cmake files that make use of generator expressions
(such as UseQt4.cmake) are retained but do not cause a empty "-D" to be output when the generator evaluates to the empty string. Fixes debug build failure on Linux using Qt4/tools/WITH_PCH.
This commit is contained in:
parent
20bc437d54
commit
306d4a1e56
1 changed files with 15 additions and 13 deletions
|
@ -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()
|
||||||
|
@ -149,7 +150,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
|
||||||
IF(GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB")
|
IF(GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB")
|
||||||
# Hack to define missing QT_NO_DEBUG with Qt 5.2
|
# Hack to define missing QT_NO_DEBUG with Qt 5.2
|
||||||
IF(_UPPER_BUILD STREQUAL "RELEASE")
|
IF(_UPPER_BUILD STREQUAL "RELEASE")
|
||||||
LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG")
|
LIST(APPEND GLOBAL_DEFINITIONS "-DQT_NO_DEBUG")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIC
|
# Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIC
|
||||||
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue