Commit f407bb5d authored by Alexander Neundorf's avatar Alexander Neundorf

FeatureSummary.cmake: only higher TYPEs can override previous TYPEs

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

Alex
parent 02d47abe
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment