Skip to content
Snippets Groups Projects
Commit 614a97a5 authored by Daniele E. Domenichelli's avatar Daniele E. Domenichelli
Browse files

FeatureSummary: Do not force OPTIONAL type in SET_PACKAGE_PROPERTIES

The OPTIONAL type is used anyway as default when the type is not set

Since RUNTIME < OPTIONAL, forcing it here forces the user to set
"RUNTIME" at the first SET_PACKAGE_PROPERTIES, otherwise it is
impossible to set it later.
Without this it is impossible, for example, to add package information
(URL and DESCRIPTION) in the FindPackage file, but allow the package
to be RUNTIME.
parent 65a0bfd8
No related branches found
No related tags found
No related merge requests found
......@@ -439,24 +439,22 @@ function(SET_PACKAGE_PROPERTIES _name _props)
endif()
# handle the TYPE
if(NOT _SPP_TYPE)
set(_SPP_TYPE OPTIONAL)
endif()
# 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()
if(DEFINED _SPP_TYPE)
# 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()
get_property(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE)
list(FIND validTypes "${_previousType}" _prevTypeIndexInList)
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}" )
# 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()
endif()
endfunction()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment