Fixed: RETURN() doesn't exit from macro but from current file (thanks Nimetu!)

This commit is contained in:
kervala 2015-12-07 13:08:27 +01:00
parent ad654a0d31
commit c31509f274

View file

@ -380,53 +380,52 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
ENDMACRO() ENDMACRO()
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp) MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
IF(NOT PCHSupport_FOUND) IF(PCHSupport_FOUND)
MESSAGE(STATUS "PCH disabled because compiler doesn't support them") # 0 => creating a new target for PCH, works for all makefiles
RETURN() # 1 => setting PCH for VC++ project, works for VC++ projects
ENDIF() # 2 => setting PCH for XCode project, works for XCode projects
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
# 0 => creating a new target for PCH, works for all makefiles SET(PCH_METHOD 1)
# 1 => setting PCH for VC++ project, works for VC++ projects ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
# 2 => setting PCH for XCode project, works for XCode projects SET(PCH_METHOD 2)
IF(CMAKE_GENERATOR MATCHES "Visual Studio") ELSE()
SET(PCH_METHOD 1) SET(PCH_METHOD 0)
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(PCH_METHOD 2)
ELSE()
SET(PCH_METHOD 0)
ENDIF()
IF(PCH_METHOD EQUAL 1)
# Auto include the precompile (useful for moc processing, since the use of
# precompiled is specified at the target level
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF() ENDIF()
SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"") IF(PCH_METHOD EQUAL 1)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}") # Auto include the precompile (useful for moc processing, since the use of
# precompiled is specified at the target level
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
#also inlude ${oldProps} to have the same compile options GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_inputh}\"") IF(${oldProps} MATCHES NOTFOUND)
ELSEIF(PCH_METHOD EQUAL 2) SET(oldProps "")
# For Xcode, cmake needs my patch to process ENDIF()
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
# When buiding out of the tree, precompiled may not be located SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
# Use full path instead. SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}") #also inlude ${oldProps} to have the same compile options
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_inputh}\"")
ELSEIF(PCH_METHOD EQUAL 2)
# For Xcode, cmake needs my patch to process
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
# When buiding out of the tree, precompiled may not be located
# Use full path instead.
GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
ELSE()
#Fallback to the "old" precompiled suppport
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF()
IF(TARGET ${_targetName}_static)
ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp})
ENDIF()
ELSE() ELSE()
#Fallback to the "old" precompiled suppport MESSAGE(STATUS "PCH disabled because compiler doesn't support them")
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF()
IF(TARGET ${_targetName}_static)
ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp})
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()