[cmake-developers] Is GET_OPTION_VALUE() a good name ?

Alexander Neundorf neundorf at kde.org
Sat Aug 7 15:41:17 EDT 2010


Hi,

in FindPackageHandleStandardArgs.cmake I have added the following function:


# Checks a list of strings (typically function/macro parameters) whether it
# contains a keyword
# (_keyword) and return the value(s) following this keyword in _outputVar.
# If _multipleValues is true, this can be more than one value.
# Then end of the values for a keyword is then determined by checking whether
# the next argument is contained in _allKeywordsList.
FUNCTION(FPHSA_GET_OPTION_VALUE _keyword _outputVar _allArgsList
                                _allKeywordsList _multipleValues)
...

Now I'd like to move that function out of this file into a separate file so it 
can be used also by other modules. When I do this, this function needs a good 
name.

Usage is like this:

# Set all known keyword names in the parameter list:
SET(_KEYWORDS  FAIL_MESSAGE REQUIRED_VARS VERSION_VAR )

# Create a real variable which contains all arguments:
SET(ALL_ARGS ${ARGN})

# Call the function, if the keyword is present the value(s) following it will 
# be returned in _FAIL_MESSAFE/_VERSION_VAR/_REQUIRED_VARS:
FPHSA_GET_OPTION_VALUE("FAIL_MESSAGE" _FAIL_MESSAGE  ALL_ARGS _KEYWORDS FALSE)
FPHSA_GET_OPTION_VALUE("VERSION_VAR"  _VERSION_VAR   ALL_ARGS _KEYWORDS FALSE)
FPHSA_GET_OPTION_VALUE("REQUIRED_VARS" _REQUIRED_VARS ALL_ARGS _KEYWORDS TRUE)

# Check if anything is left in ALL_ARGS, error out if so:
IF(ALL_ARGS)
  MESSAGE(FATAL_ERROR "Unknown keywords given to
          FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${ALL_ARGS}\"")
ENDIF(ALL_ARGS)


Currently the name would be GET_OPTION_VALUE(). Does this sound like a good 
name ? Better suggestions ?

Alex



More information about the cmake-developers mailing list