FeatureSummary.cmake: only higher TYPEs can override previous TYPEs

This way e.g. a REQUIRED cannot become OPTIONAL, only the other way round

Alex
This commit is contained in:
Alex Neundorf 2011-07-17 20:41:09 +02:00
parent 02d47abe58
commit f407bb5da2

View File

@ -192,14 +192,21 @@ FUNCTION(SET_PACKAGE_PROPERTIES _name _props)
SET(_SPP_TYPE OPTIONAL)
ENDIF()
SET(validTypes OPTIONAL RECOMMENDED REQUIRED RUNTIME )
# List the supported types, according to their priority
SET(validTypes "RUNTIME" "OPTIONAL" "RECOMMENDED" "REQUIRED" )
LIST(FIND validTypes ${_SPP_TYPE} _typeIndexInList)
IF("${_typeIndexInList}" STREQUAL "-1" )
MESSAGE(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). "
"Valid types are OPTIONAL, RECOMMENDED, REQUIRED and RUNTIME." )
ENDIF()
SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" )
GET_PROPERTY(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE)
LIST(FIND validTypes "${_previousType}" _prevTypeIndexInList)
# make sure a previously set TYPE is not overridden with a lower new TYPE:
IF("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}")
SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" )
ENDIF()
ENDFUNCTION(SET_PACKAGE_PROPERTIES)