Provides information about executable build targets. More...
#include <utilities.h>
Public Member Functions | |
virtual std::string | basename (const std::string &target) const =0 |
Get name of executable file without directory path. More... | |
virtual std::string | dirname (const std::string &target) const =0 |
Get absolute path to directory containing executable. More... | |
virtual bool | istarget (const std::string &target) const =0 |
Determine whether a given build target is known. More... | |
virtual std::string | targetuid (const std::string &target) const =0 |
Get UID of build target. More... | |
Protected Member Functions | |
IExecutableTargetInfo () | |
Constructor. More... | |
virtual | ~IExecutableTargetInfo () |
Destructor. More... | |
Provides information about executable build targets.
Within source code of a BASIS project, other SBIA executables are called only indirectly using the build target name which must be fixed and unique within the lab. The name of the output executable file of these targets may however vary and be finally set by BASIS, for example, depending on whether the project is build as part of a superproject or not. Therefore, each BASIS CMake function may adjust the output name in order to resolve name conflicts with other targets or SBIA executables.
The idea is that a target name is supposed to be stable and known to the developer as soon as the target is added to a CMakeLists.txt file, while the name of the actual executable file is not known a priori as it is set by the BASIS CMake functions during the configure step. Thus, the developer should not rely on a particular name of the executable file. Instead, they can rely on the name of the corresponding build target which was chosen by themselves when adding the target to the build configuration.
In order to get the actual file path of the built executable file, the function get_executable_path() is provided by the stdaux.h module. This function uses the static singleton instance of this class in order to map the given build target name to the name of the built and optionally installed executable. The code which initializes the required maps is generated automatically during the configuration of the build system.
Definition at line 88 of file utilities.h.
|
inlineprotected |
Constructor.
Definition at line 95 of file utilities.h.
|
inlineprotectedvirtual |
Destructor.
Definition at line 98 of file utilities.h.
|
pure virtual |
Get name of executable file without directory path.
[in] | target | Name/UID of build target. |
|
pure virtual |
Get absolute path to directory containing executable.
[in] | target | Name/UID of build target. |
|
pure virtual |
Determine whether a given build target is known.
[in] | target | Name/UID of build target. |
|
pure virtual |
Get UID of build target.
In order to be able to distinguish build targets with identical name but which are built as part of different BASIS projects, the UID of a build target is composed of the build target name as given as argument to the basis_add_* CMake functions and a namespace identifier (i.e., the project name in lowercase letters). If the specified build target name is neither known by this module nor a build target UID yet, this method prepends the namespace identifier corresponding to the project this module was built from, assuming that the caller refers to another target within the same project.
[in] | target | Name/UID of build target. |