cmakepp_lang/types/path

cmakepp_lang/types/path.cpp_is_path(result str2check)

Determines if a string is lexically convertible to an absolute filepath.

This function wraps a call to CMake’s if(IS_ABSOLUTE ...) in order to determine if the provided string is lexically convertible to an absolute filepath.

Parameters:
  • result (identifier) – An identifier to hold the result.

  • str2check – The string which may be an absolute filepath.

Returns:

TRUE if str2check is an absolute filepath and FALSE otherwise. The result is returned via result.

Return type:

bool

Example Usage

The following code snippet checks whether ${CMAKE_BINARY_DIR} is a relative directory (it always is by default):

include(cmakepp_lang/types/filepath)
cpp_is_path(result "${CMAKE_BINARY_DIR}")
message("Is a filepath: ${result}")  # Prints TRUE

Error Checking

cpp_is_path will assert that the caller has provided exactly two arguments. If this is not the case an error will be raised.