CMakePackageFinder Class Reference

The CMakePackageFinder class provides an interface to the CMake Package finder capabilities. More...

#include <ArmarXCore/core/system/cmake/CMakePackageFinder.h>

Public Member Functions

 CMakePackageFinder (const std::string &packageName, const std::filesystem::path &packagePath="", bool suppressStdErr=false, bool usePackagePathOnlyAsHint=false)
 The package with name packageName is searched with cmake during construction of this class.
 
std::string getBinaryDir () const
 
std::string getBuildDir () const
 
std::string getCMakeDir () const
 Returns the directory containing CMake scripts.
 
std::vector< std::string > getComponentExecutableNames () const
 
std::string getConfigDir () const
 Returns the path needed to find this package with cmake, i.e.
 
std::string getDataDir () const
 
std::vector< std::string > getDependencies () const
 
std::map< std::string, std::string > getDependencyPaths () const
 
std::string getExecutables () const
 
std::vector< std::string > getIncludePathList () const
 Return the include paths in a vector.
 
std::string getIncludePaths () const
 Returns the include paths separated by semi-colons.
 
std::string getInterfacePaths () const
 Returns the path to the slice (*.ice) files of a package.
 
std::string getLibraryPaths () const
 Returns the library paths seperated by semi-colons.
 
std::string getLibs () const
 
std::string getName () const
 Returns the name of the given package.
 
std::string getPackageDir () const
 Returns the top level path of a source package.
 
std::string getScenariosDir () const
 
std::string getStatechartsDir () const
 
std::string getVar (const std::string &varName) const
 Returns the content of a CMake variable.
 
const std::map< std::string, std::string > & getVars () const
 
bool packageFound () const
 Returns whether or not this package was found with cmake.
 

Static Public Member Functions

static std::string ExecCommand (std::string command, int &result, bool suppressStdErr=false)
 
static std::vector< std::string > FindAllArmarXSourcePackages ()
 
static std::vector< std::string > FindPackageIncludePathList (const std::string &packageName)
 Static function to find the include path with cmake.
 
static std::string FindPackageIncludePaths (const std::string &packageName)
 
static std::string FindPackageLibs (const std::string &packageName)
 
static std::string getArmarXCMakeTempDir ()
 return the path where the temporary cmake files are stored that are automically created by cmake.
 
static bool ReplaceCMakePackageFinderVars (std::string &string)
 Replaces occurrences like $C{PACKAGE_NAME:VAR_NAME} with their CMakePackageFinder value.
 

Protected Member Functions

std::vector< std::string > extractVariables (const std::string &cmakeVarString)
 

Static Protected Member Functions

static void _CreateSharedMutex ()
 
static bool _ParseString (const std::string &input, std::string &varName, std::string &content)
 

Protected Attributes

bool found
 
std::string packageName
 
std::map< std::string, std::string > vars
 

Detailed Description

The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.

This class calls the CMake script FindPackageX.cmake to retrieve information about a specific ArmarX package. The CMake configuration file of a package is located in the getConfigDir() directory (source packages and installations).

The available variables and their values are written to stdout and parsed by CMakePackageFinder::_ParseString(). The values of the variables can be retieved via CMakePackageFinder::getVar() or their specific convenience functions like getBuildDir().

Constructor & Destructor Documentation

◆ CMakePackageFinder()

CMakePackageFinder ( const std::string & packageName,
const std::filesystem::path & packagePath = "",
bool suppressStdErr = false,
bool usePackagePathOnlyAsHint = false )

The package with name packageName is searched with cmake during construction of this class.

Query the values with the class functions.

Parameters
packageNameName of the ArmarX package to find.
packagePathOptional path to the package. Use if a specific instance of the package should be used. This needs to be the path where the ${packageName}Config.cmake is located, so for source packages the build dir.
See also
getConfigDir()

Member Function Documentation

◆ _CreateSharedMutex()

void _CreateSharedMutex ( )
staticprotected

◆ _ParseString()

bool _ParseString ( const std::string & input,
std::string & varName,
std::string & content )
staticprotected

◆ ExecCommand()

std::string ExecCommand ( std::string command,
int & result,
bool suppressStdErr = false )
static

◆ extractVariables()

std::vector< std::string > extractVariables ( const std::string & cmakeVarString)
protected

◆ FindAllArmarXSourcePackages()

std::vector< std::string > FindAllArmarXSourcePackages ( )
static

◆ FindPackageIncludePathList()

std::vector< std::string > FindPackageIncludePathList ( const std::string & packageName)
static

Static function to find the include path with cmake.

Does use cmake built in functions and not the ArmarX cmake find script.

Parameters
packageName
Returns

◆ FindPackageIncludePaths()

std::string FindPackageIncludePaths ( const std::string & packageName)
static

◆ FindPackageLibs()

std::string FindPackageLibs ( const std::string & packageName)
static

◆ getArmarXCMakeTempDir()

std::string getArmarXCMakeTempDir ( )
static

return the path where the temporary cmake files are stored that are automically created by cmake.

If username available returns /tmp/armarxcmake-$username, otherwise /tmp.

◆ getBinaryDir()

std::string getBinaryDir ( ) const
inline

◆ getBuildDir()

std::string getBuildDir ( ) const
inline

◆ getCMakeDir()

std::string getCMakeDir ( ) const
inline

Returns the directory containing CMake scripts.

Note
This is not the CMake Config Dir!
See also
getConfigDir()

◆ getComponentExecutableNames()

std::vector< std::string > getComponentExecutableNames ( ) const

◆ getConfigDir()

std::string getConfigDir ( ) const
inline

Returns the path needed to find this package with cmake, i.e.

the dir where ${PACKAGENAME}Config.cmake resides.

◆ getDataDir()

std::string getDataDir ( ) const
inline

◆ getDependencies()

std::vector< std::string > getDependencies ( ) const

◆ getDependencyPaths()

std::map< std::string, std::string > getDependencyPaths ( ) const

◆ getExecutables()

std::string getExecutables ( ) const

◆ getIncludePathList()

std::vector< std::string > getIncludePathList ( ) const

Return the include paths in a vector.

Same as getIncludePaths() but already splitted.

◆ getIncludePaths()

std::string getIncludePaths ( ) const
inline

Returns the include paths separated by semi-colons.

◆ getInterfacePaths()

std::string getInterfacePaths ( ) const
inline

Returns the path to the slice (*.ice) files of a package.

Note
The generated slice files are relative getIncludePaths() with the same directory structure.

◆ getLibraryPaths()

std::string getLibraryPaths ( ) const
inline

Returns the library paths seperated by semi-colons.

◆ getLibs()

std::string getLibs ( ) const
inline

◆ getName()

std::string getName ( ) const

Returns the name of the given package.

Same name as given in constructor.

◆ getPackageDir()

std::string getPackageDir ( ) const
inline

Returns the top level path of a source package.

Does not work for installed packages, so use with caution. To get the package config dir, e.g. for cmake, use getConfigDir().

◆ getScenariosDir()

std::string getScenariosDir ( ) const
inline

◆ getStatechartsDir()

std::string getStatechartsDir ( ) const
inline

◆ getVar()

std::string getVar ( const std::string & varName) const

Returns the content of a CMake variable.

Usually there exists a dedicated function for all variables e.g. getIncludePaths()

Parameters
varNameName of the CMake Variable
Returns
Content of the variable.

◆ getVars()

const std::map< std::string, std::string > & getVars ( ) const

◆ packageFound()

bool packageFound ( ) const

Returns whether or not this package was found with cmake.

◆ ReplaceCMakePackageFinderVars()

bool ReplaceCMakePackageFinderVars ( std::string & string)
static

Replaces occurrences like $C{PACKAGE_NAME:VAR_NAME} with their CMakePackageFinder value.

E.g. $C{ArmarXCore:BINARY_DIR} could be replaced with /home/user/armarx/ArmarXCore/build/bin.

Parameters
stringContents in this string will be replaced.
Returns
True if something was replaced.

Member Data Documentation

◆ found

bool found
protected

◆ packageName

std::string packageName
protected

◆ vars

std::map<std::string, std::string> vars
protected

The documentation for this class was generated from the following files: