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. More...
 
std::string getBinaryDir () const
 
std::string getBuildDir () const
 
std::string getCMakeDir () const
 Returns the directory containing CMake scripts. More...
 
std::vector< std::string > getComponentExecutableNames () const
 
std::string getConfigDir () const
 Returns the path needed to find this package with cmake, i.e. More...
 
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. More...
 
std::string getIncludePaths () const
 Returns the include paths separated by semi-colons. More...
 
std::string getInterfacePaths () const
 Returns the path to the slice (*.ice) files of a package. More...
 
std::string getLibraryPaths () const
 Returns the library paths seperated by semi-colons. More...
 
std::string getLibs () const
 
std::string getName () const
 Returns the name of the given package. More...
 
std::string getPackageDir () const
 Returns the top level path of a source package. More...
 
std::string getScenariosDir () const
 
std::string getStatechartsDir () const
 
std::string getVar (const std::string &varName) const
 Returns the content of a CMake variable. More...
 
const std::map< std::string, std::string > & getVars () const
 
bool packageFound () const
 Returns whether or not this package was found with cmake. More...
 

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. More...
 
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. More...
 
static bool ReplaceCMakePackageFinderVars (std::string &string)
 Replaces occurrences like $C{PACKAGE_NAME:VAR_NAME} with their CMakePackageFinder value. More...
 

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().

Definition at line 53 of file CMakePackageFinder.h.

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()

Definition at line 236 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ _CreateSharedMutex()

void _CreateSharedMutex ( )
staticprotected

Definition at line 566 of file CMakePackageFinder.cpp.

◆ _ParseString()

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

Definition at line 537 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

◆ ExecCommand()

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

Definition at line 412 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

◆ extractVariables()

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

Definition at line 572 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindAllArmarXSourcePackages()

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

Definition at line 438 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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

Definition at line 312 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindPackageIncludePaths()

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

Definition at line 372 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindPackageLibs()

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

Definition at line 337 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:

◆ 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.

Definition at line 609 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

◆ getBinaryDir()

std::string getBinaryDir ( ) const
inline

Definition at line 159 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBuildDir()

std::string getBuildDir ( ) const
inline

Definition at line 136 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCMakeDir()

std::string getCMakeDir ( ) const
inline

Returns the directory containing CMake scripts.

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

Definition at line 155 of file CMakePackageFinder.h.

+ Here is the call graph for this function:

◆ getComponentExecutableNames()

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

Definition at line 666 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

Definition at line 102 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataDir()

std::string getDataDir ( ) const
inline

Definition at line 176 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDependencies()

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

Definition at line 507 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:

◆ getDependencyPaths()

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

Definition at line 515 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:

◆ getExecutables()

std::string getExecutables ( ) const

Definition at line 661 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:

◆ getIncludePathList()

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

Return the include paths in a vector.

Same as getIncludePaths() but already splitted.

Definition at line 601 of file CMakePackageFinder.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIncludePaths()

std::string getIncludePaths ( ) const
inline

Returns the include paths separated by semi-colons.

Definition at line 110 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

Definition at line 172 of file CMakePackageFinder.h.

+ Here is the call graph for this function:

◆ getLibraryPaths()

std::string getLibraryPaths ( ) const
inline

Returns the library paths seperated by semi-colons.

Definition at line 128 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLibs()

std::string getLibs ( ) const
inline

Definition at line 132 of file CMakePackageFinder.h.

+ Here is the call graph for this function:

◆ getName()

std::string getName ( ) const

Returns the name of the given package.

Same name as given in constructor.

Definition at line 480 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

◆ 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().

Definition at line 144 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScenariosDir()

std::string getScenariosDir ( ) const
inline

Definition at line 180 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatechartsDir()

std::string getStatechartsDir ( ) const
inline

Definition at line 115 of file CMakePackageFinder.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

Definition at line 495 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

◆ getVars()

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

Definition at line 490 of file CMakePackageFinder.cpp.

◆ packageFound()

bool packageFound ( ) const

Returns whether or not this package was found with cmake.

Definition at line 485 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

◆ 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.

Definition at line 630 of file CMakePackageFinder.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ found

bool found
protected

Definition at line 205 of file CMakePackageFinder.h.

◆ packageName

std::string packageName
protected

Definition at line 207 of file CMakePackageFinder.h.

◆ vars

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

Definition at line 206 of file CMakePackageFinder.h.


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