Fixed: PCH with Qt 5 and CMake 2.8.11
This commit is contained in:
parent
a9cabeff7a
commit
27f9261d5b
1 changed files with 39 additions and 13 deletions
|
@ -10,7 +10,6 @@
|
|||
|
||||
IF(MSVC)
|
||||
SET(PCHSupport_FOUND TRUE)
|
||||
SET(_PCH_include_prefix "/I")
|
||||
ELSE(MSVC)
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
|
||||
|
@ -26,16 +25,14 @@ ELSE(MSVC)
|
|||
# TODO: make tests for other compilers than GCC
|
||||
SET(PCHSupport_FOUND TRUE)
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
SET(_PCH_include_prefix "-I")
|
||||
ENDIF(MSVC)
|
||||
|
||||
# Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs
|
||||
MACRO(PCH_SET_COMPILE_FLAGS _target)
|
||||
SET(PCH_FLAGS)
|
||||
SET(PCH_ARCHS)
|
||||
SET(PCH_ARCHS)
|
||||
|
||||
SET(_FLAGS)
|
||||
|
||||
LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD)
|
||||
|
@ -46,24 +43,33 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
|
|||
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
|
||||
LIST(APPEND _FLAGS " -fPIC")
|
||||
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
|
||||
|
||||
GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE)
|
||||
IF(_pic)
|
||||
LIST(APPEND _FLAGS " -fPIE")
|
||||
ENDIF(_pic)
|
||||
ENDIF(NOT MSVC)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
|
||||
FOREACH(item ${DIRINC})
|
||||
LIST(APPEND _FLAGS " ${_PCH_include_prefix}\"${item}\"")
|
||||
LIST(APPEND _FLAGS " -I\"${item}\"")
|
||||
ENDFOREACH(item)
|
||||
|
||||
# Required for CMake 2.6
|
||||
SET(GLOBAL_DEFINITIONS)
|
||||
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
|
||||
FOREACH(item ${DEFINITIONS})
|
||||
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
|
||||
ENDFOREACH(item)
|
||||
IF(DEFINITIONS)
|
||||
FOREACH(item ${DEFINITIONS})
|
||||
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
|
||||
ENDFOREACH(item)
|
||||
ENDIF(DEFINITIONS)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
|
||||
FOREACH(item ${DEFINITIONS})
|
||||
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
|
||||
ENDFOREACH(item)
|
||||
IF(DEFINITIONS)
|
||||
FOREACH(item ${DEFINITIONS})
|
||||
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
|
||||
ENDFOREACH(item)
|
||||
ENDIF(DEFINITIONS)
|
||||
|
||||
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
|
||||
IF(oldProps)
|
||||
|
@ -75,6 +81,27 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
|
|||
LIST(APPEND _FLAGS " ${oldPropsBuild}")
|
||||
ENDIF(oldPropsBuild)
|
||||
|
||||
GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES)
|
||||
IF(DIRINC)
|
||||
FOREACH(item ${DIRINC})
|
||||
LIST(APPEND _FLAGS " -I\"${item}\"")
|
||||
ENDFOREACH(item)
|
||||
ENDIF(DIRINC)
|
||||
|
||||
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
|
||||
IF(DEFINITIONS)
|
||||
FOREACH(item ${DEFINITIONS})
|
||||
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
|
||||
ENDFOREACH(item)
|
||||
ENDIF(DEFINITIONS)
|
||||
|
||||
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD})
|
||||
IF(DEFINITIONS)
|
||||
FOREACH(item ${DEFINITIONS})
|
||||
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
|
||||
ENDFOREACH(item)
|
||||
ENDIF(DEFINITIONS)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
|
||||
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
|
||||
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
|
||||
|
@ -90,7 +117,6 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
|
|||
SEPARATE_ARGUMENTS(_FLAGS)
|
||||
ENDIF(MSVC)
|
||||
|
||||
|
||||
IF(CLANG)
|
||||
# Determining all architectures and get common flags
|
||||
SET(_ARCH_NEXT)
|
||||
|
|
Loading…
Reference in a new issue