Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/cmake/ActsComponentsHelpers.cmake is written in an unsupported language. File is not indexed.

0001 # Provide helper functions to simplify the handling of (optional) components
0002 #
0003 # Components must always be placed in a separate directory which can than
0004 # be added using either of the two provided functions
0005 #
0006 #     add_component(<SUBDIR> <NAME>)
0007 #     add_component_if(<SUBDIR> <NAME> ...) # for optional components
0008 #
0009 # Both functions are wrappers around `add_subdirectory` that also register a
0010 # component under the given name. All additional arguments to the second
0011 # function are treated as a boolean expression that determines whether the
0012 # subdirectory should be added and the component registered. The list of
0013 # components is stored in the global `_components` variable. If
0014 # components are added from a subdirectory, this variable must be propagated to
0015 # the global scope using the following helper macro:
0016 #
0017 #     propagate_components_to_parent()
0018 #
0019 # For cases, where a subdirectory needs to be optionally included but does not
0020 # need to be registered as a component, the following helper function can be
0021 # used
0022 #
0023 #     add_subdirectory_if(<SUBDIR> ...)
0024 #
0025 # where all additional arguments are again treated as a boolean expression that
0026 # determines whether the subdirectory should be added.
0027 
0028 set(_components)
0029 
0030 # add an optional directory and register its name as a component
0031 function(add_component_if path name)
0032     file(
0033         RELATIVE_PATH
0034         _rel
0035         ${PROJECT_SOURCE_DIR}
0036         "${CMAKE_CURRENT_SOURCE_DIR}/${path}"
0037     )
0038     if(${ARGN})
0039         list(APPEND _components "${name}")
0040         # propagate variable outside function scope
0041         set(_components "${_components}" PARENT_SCOPE)
0042         message(STATUS "Enable component '${name}' in '${_rel}'")
0043         add_subdirectory(${path})
0044     else()
0045         message(STATUS "Ignore component '${name}' in '${_rel}'")
0046     endif()
0047 endfunction()
0048 
0049 # add a directory and register its name as a component
0050 macro(add_component path name)
0051     add_component_if(${path} ${name} TRUE)
0052 endmacro()
0053 
0054 # propagate the list of components to the parent scope
0055 macro(propagate_components_to_parent)
0056     set(_components "${_components}" PARENT_SCOPE)
0057 endmacro()
0058 
0059 # add an optional subdirectory that is **not** registered as a component
0060 function(add_subdirectory_if path)
0061     file(
0062         RELATIVE_PATH
0063         _rel
0064         ${PROJECT_SOURCE_DIR}
0065         "${CMAKE_CURRENT_SOURCE_DIR}/${path}"
0066     )
0067     if(${ARGN})
0068         message(STATUS "Enable subdirectory '${_rel}'")
0069         add_subdirectory(${path})
0070     else()
0071         message(STATUS "Ignore subdirectory '${_rel}'")
0072     endif()
0073 endfunction()