cmakepp_lang/types/fxn

cmakepp_lang/types/fxn.cpp_is_fxn(result str2check)

Determines if a string is lexically convertible to a command.

This function wraps a call to CMake’s if(COMMAND ...) in order to determine if the provided string is lexically convertible to a command or not. Commands can be native CMake functions or user-defined macro/functions. It should be noted that for CMakePP functions it is the mangled name of the function which is identified as a command.

Parameters:
  • result (desc) – Name for variable which will hold the result of the check.

  • str2check – The string which may be a command.

Returns:

TRUE if str2check is a command and FALSE otherwise. The result is returned via result.

Return type:

bool

Example Usage

The following code snippet checks whether add_subdirectory is a command:

include(cmakepp_lang/types/fxn)
cpp_is_fxn(result add_subdirectory)
message("Is a command: ${result}")  # Prints TRUE