CMakePackageFinder.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX::
19 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #include "CMakePackageFinder.h"
32 
33 #include "../../rapidxml/wrapper/RapidXmlReader.h"
35 
36 #include <boost/interprocess/managed_shared_memory.hpp>
37 #include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
38 #include <boost/interprocess/sync/interprocess_condition.hpp>
39 
40 #include <SimoxUtility/algorithm/string/string_tools.h>
41 #include <boost/algorithm/string/regex.hpp>
42 #include <boost/regex.hpp>
43 #include <boost/interprocess/sync/file_lock.hpp>
44 #include <boost/interprocess/sync/scoped_lock.hpp>
45 #include <boost/interprocess/sync/sharable_lock.hpp>
46 #include <boost/thread/thread_time.hpp>
47 
48 #include <filesystem>
49 #include <sstream>
50 #include <memory>
51 #include <ctime>
52 #include <mutex>
53 #include <cstdlib>
54 
55 #define SCRIPT_PATH "ArmarXCore/core/system/cmake/FindPackageX.cmake"
56 #define CACHE_PATH "/ArmarXCMakeCache_" + (getenv("USER")?getenv("USER"):"DUMMY_USER")
57 
58 extern char ** environ;
59 
60 
61 namespace armarx
62 {
63  std::string getHomeDir()
64  {
65  char* homePathC = getenv("HOME");
66  std::string homePath;
67  if (homePathC)
68  {
69  homePath = homePathC;
70  }
71  return homePath;
72  }
73 
74  std::shared_ptr<boost::interprocess::file_lock> getFileLock(std::string lockName, bool verbose = false)
75  {
76  std::string path = remove_trailing_separator(fs::temp_directory_path().string() + CACHE_PATH);
77  if (verbose)
78  {
79  std::cout << "getFileLock( path = " << path << ")" << std::endl;
80  }
81  if (!std::filesystem::exists(path))
82  {
83  if (verbose)
84  {
85  std::cout << "path does not exist" << std::endl;
86  }
87  if (!std::filesystem::create_directories(path))
88  {
89  if (verbose)
90  {
91  std::cout << "failed to create directories" << std::endl;
92  }
93  return std::shared_ptr<boost::interprocess::file_lock>();
94  }
95  }
96  path += "/" + lockName;
97  if (verbose)
98  {
99  std::cout << "lock file = " << path << std::endl;
100  }
101  if (!std::filesystem::exists(path))
102  {
103  if (verbose)
104  {
105  std::cout << "touch " << path << std::endl;
106  }
107  //touch file
108  std::ofstream file(path);
109  file.close();
110  }
111  if (verbose)
112  {
113  std::cout << "build lock with " << path << std::endl;
114  }
115  return std::shared_ptr<boost::interprocess::file_lock>(new boost::interprocess::file_lock(path.c_str()));
116  }
117 
118  std::shared_ptr<boost::interprocess::file_lock> CreateAndCheckFileLock(const std::string& name)
119  {
120  ARMARX_TRACE;
121  std::shared_ptr<boost::interprocess::file_lock> lock(getFileLock(name, false));
122  if (!lock)
123  {
124  ARMARX_WARNING << "Failed to create file lock! retrying...";
125  lock = getFileLock(name, true);
126  ARMARX_CHECK_NOT_NULL(lock) << "Failed to get file lock '" + name + "'";
127  }
128  return lock;
129  }
130 
131  const std::shared_ptr<boost::interprocess::file_lock>& CacheFileLock()
132  {
133  ARMARX_TRACE;
134  static auto lock = CreateAndCheckFileLock(".cachelock");
135  ARMARX_CHECK_NOT_NULL(lock);
136  return lock;
137  }
138 
139  const std::shared_ptr<boost::interprocess::file_lock>& CMakeFileLock()
140  {
141  ARMARX_TRACE;
142  static auto lock = CreateAndCheckFileLock(".cmakelock");
143  ARMARX_CHECK_NOT_NULL(lock);
144  return lock;
145  }
146 
147  std::mutex& CMakeMutex()
148  {
149  static std::mutex mx;
150  return mx;
151  }
152 
153  using ScopedFileLockPtr = std::shared_ptr<boost::interprocess::scoped_lock<boost::interprocess::file_lock>>;
154 
156  {
157  std::unique_lock lock(CMakeMutex());
158 
159  ScopedFileLockPtr lockPtr(new boost::interprocess::scoped_lock<boost::interprocess::file_lock>(*CMakeFileLock(),
160  boost::get_system_time() + boost::posix_time::milliseconds(50)));
161  while (!lockPtr->owns())
162  {
163  lockPtr->timed_lock(boost::get_system_time() + boost::posix_time::milliseconds(50));
164  }
165  return lockPtr;
166  }
167 
168  bool readCMakeCache(const std::string& packageName, std::string& packageContent)
169  {
170  auto start = IceUtil::Time::now();
171  std::string path = std::filesystem::temp_directory_path().string() + CACHE_PATH;
172  path += "/" + packageName;
173  if (!std::filesystem::exists(path))
174  {
175  return false;
176  }
177  else
178  {
179 
180  const auto writeTime = std::filesystem::last_write_time(path);
181  const auto now = decltype(writeTime)::clock::now();
182  long age = std::chrono::duration_cast<std::chrono::seconds>(now - writeTime).count();
183  // ARMARX_INFO_S << VAROUT(packageName) << VAROUT(age) << VAROUT(std::asctime(std::localtime(&writeTime)));
184  boost::interprocess::sharable_lock<boost::interprocess::file_lock> e_lock(*CacheFileLock());
185  packageContent = RapidXmlReader::ReadFileContents(path);
186  auto dura = (IceUtil::Time::now() - start).toMilliSecondsDouble();
187  if (dura > 10000)
188  {
189  ARMARX_INFO_S << packageName << " from cache locked for " << dura;
190  }
191  if (age < 10)
192  {
193  return true;
194  }
195  else
196  {
197  return false;
198  }
199  }
200  }
201 
202  bool updateCMakeCache(const std::string& packageName, const std::string& packageContent)
203  {
204  auto start = IceUtil::Time::now();
205  std::string path = std::filesystem::temp_directory_path().string() + CACHE_PATH;
206  if (!std::filesystem::exists(path))
207  {
208  if (!std::filesystem::create_directories(path))
209  {
210  return false;
211  }
212  }
213  path = path + "/" + packageName;
214  boost::interprocess::scoped_lock<boost::interprocess::file_lock> e_lock(*CacheFileLock());
215  // std::string existingPackageContent = RapidXmlReader::ReadFileContents(path);
216  // if (existingPackageContent != packageContent)
217  {
218  std::ofstream file(path);
219  file << packageContent;
220  }
221  // ARMARX_IMPORTANT_S << "Updateing cmakecache " << VAROUT(packageName) << VAROUT(path);
222  auto dura = (IceUtil::Time::now() - start).toMilliSecondsDouble();
223  if (dura > 10000)
224  {
225  ARMARX_INFO_S << packageName << " update cache locked for " << dura;
226  }
227  return true;
228  }
229 
230  boost::interprocess::interprocess_upgradable_mutex* memoryMutex = nullptr;
231  std::shared_ptr<boost::interprocess::managed_shared_memory> sharedMemorySegment;
232  std::mutex cmakePackageMutex;
233 
234 
235 
236  CMakePackageFinder::CMakePackageFinder(const std::string& packageName, const std::filesystem::path& packagePath, bool suppressStdErr, bool usePackagePathOnlyAsHint) :
237  found(false),
238  packageName(simox::alg::trim_copy(packageName))
239  {
240  if (this->packageName.empty())
241  {
242  ARMARX_WARNING << "CMakePackageFinder: Package name must not be empty";
243  }
244  static std::string scriptPath;
245  {
246 
247  std::unique_lock lock(cmakePackageMutex);
248 
249  if (scriptPath.empty())
250  {
251  // Somehow this call fails sometimes if many components are started seperatly
252  // So try on fail again with another path
253  auto start = IceUtil::Time::now();
254  auto list = FindPackageIncludePathList("ArmarXCore");
255  auto dura = (IceUtil::Time::now() - start);
256 
257  if (dura.toMilliSeconds() > 10000)
258  {
259  ARMARX_INFO_S << "Cmakefinder for initial core search took long - Duration: " << dura.toMilliSeconds();
260  }
261 
262  if (!ArmarXDataPath::getAbsolutePath(SCRIPT_PATH, scriptPath, list, false))
263  {
264  ARMARX_WARNING_S << "Finding FindPackageX.cmake failed - trying again with different path";
265 
266  if (!ArmarXDataPath::getAbsolutePath(std::string("../source/") + SCRIPT_PATH, scriptPath))
267  {
268  return;
269  }
270  }
271  }
272  }
273  // ARMARX_INFO_S << scriptPath;
274  int result;
275 
276  auto start = IceUtil::Time::now();
277  std::string resultStr;
278  std::string tmpDir = getArmarXCMakeTempDir();
279  try
280  {
281  if (!packagePath.empty())
282  {
283  resultStr = ExecCommand("cd " + tmpDir + "; cmake -DPACKAGE=" + this->packageName + " -DPACKAGEBUILDPATH" + (usePackagePathOnlyAsHint ? "Hint" : "") + "=" + packagePath.string() + " -P " + scriptPath, result, suppressStdErr);
284  }
285  else if (!readCMakeCache(this->packageName, resultStr))
286  {
287  resultStr = ExecCommand("cd " + tmpDir + "; cmake -DPACKAGE=" + this->packageName + " -P " + scriptPath, result, suppressStdErr);
288  updateCMakeCache(this->packageName, resultStr);
289 
290  }
291  }
292  catch (...)
293  {
294 
295 
296  }
297 
298 
299  auto dura = (IceUtil::Time::now() - start);
300 
301  if (dura.toMilliSeconds() > 10000)
302  {
303  ARMARX_INFO_S << "Cmakefinder took long for package " << packagePath << " - Duration: " << dura.toMilliSeconds();
304  }
305 
306  std::vector<std::string> resultList;
307  resultList = extractVariables(resultStr);
308 
309  // ARMARX_INFO_S << resultList;
310  }
311 
312  std::vector<std::string> CMakePackageFinder::FindPackageIncludePathList(const std::string& packageName)
313  {
314  // _CreateSharedMutex();
315 
316  std::string output = FindPackageIncludePaths(packageName);
317  std::vector<std::string> result;
318  boost::split_regex(result,
319  output,
320  boost::regex("-I")
321  );
322 
323  for (size_t i = 0; i < result.size(); i++)
324  {
325  simox::alg::trim(result[i]);
326 
327  if (result[i].empty())
328  {
329  result.erase(result.begin() + i);
330  i--;
331  }
332  }
333 
334  return result;
335  }
336 
337  std::string CMakePackageFinder::FindPackageLibs(const std::string& packageName)
338  {
339  // boost::interprocess::scoped_lock<boost::interprocess::file_lock> e_lock(*CMakeFileLock());
340  auto lock = lockCMake();
341  auto start = IceUtil::Time::now();
342  try
343  {
344 
345  std::stringstream str;
346  str << "cmake --find-package -DNAME=" << packageName << " -DLANGUAGE=CXX -DCOMPILER_ID=GNU -DMODE=LINK";
347  int result;
348  std::string output = ExecCommand(str.str(), result);
349 
350  if (result != 0)
351  {
352  return "";
353  }
354 
355 
356  auto dura = (IceUtil::Time::now() - start).toMilliSecondsDouble();
357  if (dura > 10)
358  {
359  // ARMARX_INFO_S << packageName << " locked for " << dura;
360  }
361  return output;
362 
363  }
364  catch (...)
365  {
366  return "";
367  }
368 
369  }
370 
371 
372  std::string CMakePackageFinder::FindPackageIncludePaths(const std::string& packageName)
373  {
374  auto start = IceUtil::Time::now();
375  // std::cout << start.toDateTime() << " Waiting for lock;" << std::endl;
376  auto lock = lockCMake();
377  // auto dura = (IceUtil::Time::now() - start).toMilliSecondsDouble();
378  // if(dura > 1000)
379  // ARMARX_IMPORTANT_S << " waited for " << dura;
380  start = IceUtil::Time::now();
381  try
382  {
383  std::string tmpDir = getArmarXCMakeTempDir();
384  std::stringstream str;
385  str << "cd " + tmpDir + ";cmake --find-package -DNAME=" << packageName << " -DLANGUAGE=CXX -DCOMPILER_ID=GNU -DMODE=COMPILE";
386  int result;
387  std::string output = ExecCommand(str.str(), result);
388 
389  if (result != 0)
390  {
391  ARMARX_IMPORTANT_S << packageName << " search failed - output: " << output;
392  return "";
393  }
394 
395 
396  auto dura = (IceUtil::Time::now() - start).toMilliSecondsDouble();
397  if (dura > 10)
398  {
399  // ARMARX_INFO_S << packageName << " locked for " << dura;
400  }
401  return output;
402  }
403  catch (...)
404  {
405 
406 
407  return "";
408  }
409 
410  }
411 
412  std::string CMakePackageFinder::ExecCommand(std::string command, int& result, bool suppressStdErr)
413  {
414  auto start = IceUtil::Time::now();
415  if (suppressStdErr)
416  {
417  command += " 2>/dev/null";
418  }
419  ARMARX_DEBUG << "Cmd: " << command;
420  FILE* fp = popen(command.c_str(), "r");
421  char line [50];
422  std::string output;
423 
424  while (fgets(line, sizeof line, fp))
425  {
426  output += line;
427  }
428 
429  result = pclose(fp) / 256;
430  auto dura = (IceUtil::Time::now() - start).toMilliSecondsDouble();
431  if (dura > 1000)
432  {
433  ARMARX_INFO_S << "ExecCommand took " << dura << " \n command: " << command;
434  }
435  return output;
436  }
437 
439  {
440  std::vector<std::string> result;
441  using namespace std::filesystem;
442 
443  char ** env;
444 
445  env = environ;
446 
447  for (; *env; ++env) {
448  const std::string envVar(*env);
449  ARMARX_DEBUG << "Retrieved environment variable " << envVar;
450 
451  const std::vector<std::string> elements = simox::alg::split(envVar, "=");
452  if(not (elements.size() == 2))
453  {
454  continue;
455  }
456 
457  const std::string& envVarName = elements.front();
458  const std::string& envVarValue = elements.back();
459 
460  if(simox::alg::ends_with(envVarName, "_DIR"))
461  {
462  const std::string packageName = simox::alg::remove_suffix(envVarName, "_DIR");
463  auto pckFinder = CMakePackageFinder {packageName, envVarValue, true};
464 
465  ARMARX_DEBUG << "Package name: " << packageName;
466  ARMARX_DEBUG << "Path: " << envVarValue;
467 
468  // check if this is really a package
469  if (pckFinder.packageFound() && !pckFinder.getBuildDir().empty())
470  {
471  ARMARX_DEBUG << "Found package " << packageName;
472  result.push_back(packageName);
473  }
474  }
475  }
476 
477  return result;
478  }
479 
480  std::string CMakePackageFinder::getName() const
481  {
482  return packageName;
483  }
484 
486  {
487  return found;
488  }
489 
490  const std::map<std::string, std::string>& CMakePackageFinder::getVars() const
491  {
492  return vars;
493  }
494 
495  std::string CMakePackageFinder::getVar(const std::string& varName) const
496  {
497  std::map<std::string, std::string>::const_iterator it = vars.find(varName);
498 
499  if (it != vars.end())
500  {
501  return it->second;
502  }
503 
504  return "";
505  }
506 
507  std::vector<std::string> CMakePackageFinder::getDependencies() const
508  {
509  auto depListString = getVar("DEPENDENCIES");
510  std::vector<std::string> resultList = armarx::Split(depListString, ";", true, true);
511 
512  return resultList;
513  }
514 
515  std::map<std::string, std::string> CMakePackageFinder::getDependencyPaths() const
516  {
517  // is of type "package1:package1Path;package2:packagePath2"
518  auto depListString = getVar("PACKAGE_DEPENDENCY_PATHS");
519  std::vector<std::string> resultList = simox::alg::split(depListString, ";");
520  std::map<std::string, std::string> resultMap;
521 
522  for (auto& depPairString : resultList)
523  {
524  std::vector<std::string> depPair = simox::alg::split(depPairString, ":");
525 
526  if (depPair.size() < 2)
527  {
528  continue;
529  }
530 
531  resultMap[depPair.at(0)] = depPair.at(1);
532  }
533 
534  return resultMap;
535  }
536 
537  bool CMakePackageFinder::_ParseString(const std::string& input, std::string& varName, std::string& content)
538  {
539  // ARMARX_INFO_S << "input: " << input;
540  const boost::regex e("\\-\\- ([a-zA-Z0-9_]+):(.+)");
541  boost::match_results<std::string::const_iterator> what;
542 
543  bool found = boost::regex_search(input, what, e);
544 
545  for (size_t i = 1; i < what.size(); i++)
546  {
547 
548  if (i == 1)
549  {
550  varName = what[i];
551  }
552  else if (i == 2)
553  {
554  content = what[i];
555  }
556 
557  // ARMARX_INFO_S << VAROUT(varName);
558  }
559 
560  simox::alg::trim(varName);
561  simox::alg::trim(content);
562  return found;
563 
564  }
565 
567  {
568 
569  }
570 
571 
572  std::vector<std::string> CMakePackageFinder::extractVariables(const std::string& cmakeVarString)
573  {
574  std::vector<std::string> resultList = simox::alg::split(cmakeVarString, "\n");
575 
576  for (size_t i = 0; i < resultList.size(); i++)
577  {
578  simox::alg::trim(resultList[i]);
579 
580  if (resultList[i].empty())
581  {
582  resultList.erase(resultList.begin() + i);
583  i--;
584  }
585  else
586  {
587  std::string var;
588  std::string content;
589 
590  if (_ParseString(resultList[i], var, content))
591  {
592  found = true;
593  vars[var] = content;
594  }
595  }
596  }
597 
598  return resultList;
599  }
600 
601  std::vector<std::string> armarx::CMakePackageFinder::getIncludePathList() const
602  {
603  auto depListString = getIncludePaths();
604  std::vector<std::string> resultList = simox::alg::split(depListString, ";");
605  return resultList;
606  }
607 
608 
610  {
611  const std::string tmpDir = "/tmp";
612  std::string result = tmpDir;
613  char* username = getenv("USER");
614  if (username)
615  {
616  std::string usernameString = std::string(username);
617  simox::alg::trim(usernameString);
618  result += "/armarxcmake-" + usernameString;
619  if (!std::filesystem::exists(result))
620  {
621  if (!std::filesystem::create_directories(result))
622  {
623  result = tmpDir;
624  }
625  }
626  }
627  return result;
628  }
629 
631  {
632  const boost::regex e("\\$C\\{([a-zA-Z0-9_\\-]+):([a-zA-Z0-9_\\-]+)\\}");
633  boost::match_results<std::string::const_iterator> what;
634  bool found = boost::regex_search(string, what, e);
635  std::map<std::string, CMakePackageFinder> finders;
636  if (found)
637  {
638  for (size_t i = 1; i < what.size(); i += 3)
639  {
640  std::string package = what[i];
641  auto it = finders.find(package);
642  if (it == finders.end())
643  {
644  it = finders.insert(
645  std::make_pair(package, CMakePackageFinderCache::GlobalCache.findPackage(package))).first;
646  // it = finders.find(package);
647  }
648  std::string var = what[i + 1];
649 
650 
651  auto envVar = it->second.getVar(var);
652  string = boost::regex_replace(string, e, std::string(envVar));
653  ARMARX_DEBUG << "Replacing '" << var << "' with '" << std::string(envVar) << "'";
654  }
655  }
656  return found;
657 
658  }
659 
660  std::string
662  {
663  return getVar("EXECUTABLE");
664  }
665 
666  std::vector<std::string> CMakePackageFinder::getComponentExecutableNames() const
667  {
668  namespace fs = std::filesystem;
669 
670  const fs::path componentReportFilename =
671  fs::path(getBuildDir()) / "component_executables_report.txt";
672  if (fs::exists(componentReportFilename))
673  {
674  std::ifstream componentReportFile(componentReportFilename);
675  if (componentReportFile.bad())
676  {
677  ARMARX_WARNING << "Could not load file: " << componentReportFilename;
678  return {};
679  }
680 
681  const std::string content(std::istreambuf_iterator<char>{componentReportFile}, {});
682  return simox::alg::split(content, "\n");
683  }
684 
685  // TODO legacy mode. Remove after full migration
686  if (vars.count("EXECUTABLE") > 0)
687  {
688  return simox::alg::split(getVar("EXECUTABLE"), " ");
689  }
690 
691  ARMARX_WARNING << "No component executables available. Check if `" << packageName << "/build/component_executables_report.txt` is generated properly and EXECUTABLE variable (legacy).";
692  return {};
693  }
694 } // namespace armarx
ARMARX_IMPORTANT_S
#define ARMARX_IMPORTANT_S
Definition: Logging.h:203
armarx::CMakePackageFinder::vars
std::map< std::string, std::string > vars
Definition: CMakePackageFinder.h:206
armarx::CacheFileLock
const std::shared_ptr< boost::interprocess::file_lock > & CacheFileLock()
Definition: CMakePackageFinder.cpp:131
armarx::lockCMake
ScopedFileLockPtr lockCMake()
Definition: CMakePackageFinder.cpp:155
str
std::string str(const T &t)
Definition: UserAssistedSegmenterGuiWidgetController.cpp:42
CACHE_PATH
#define CACHE_PATH
Definition: CMakePackageFinder.cpp:56
armarx::RapidXmlReader::ReadFileContents
static std::string ReadFileContents(const std::string &path)
Definition: RapidXmlReader.h:462
armarx::CMakePackageFinder::packageFound
bool packageFound() const
Returns whether or not this package was found with cmake.
Definition: CMakePackageFinder.cpp:485
armarx::cmakePackageMutex
std::mutex cmakePackageMutex
Definition: CMakePackageFinder.cpp:232
armarx::CMakePackageFinder::getVar
std::string getVar(const std::string &varName) const
Returns the content of a CMake variable.
Definition: CMakePackageFinder.cpp:495
armarx::CMakePackageFinder::getExecutables
std::string getExecutables() const
Definition: CMakePackageFinder.cpp:661
armarx::CMakePackageFinder::FindAllArmarXSourcePackages
static std::vector< std::string > FindAllArmarXSourcePackages()
Definition: CMakePackageFinder.cpp:438
list
list(APPEND SOURCES ${QT_RESOURCES}) set(COMPONENT_LIBS ArmarXGui ArmarXCoreObservers ArmarXCoreEigen3Variants PlotterController $
Definition: CMakeLists.txt:49
armarx::remove_trailing_separator
fs::path remove_trailing_separator(fs::path p)
Definition: filesystem.h:32
armarx::getFileLock
std::shared_ptr< boost::interprocess::file_lock > getFileLock(std::string lockName, bool verbose=false)
Definition: CMakePackageFinder.cpp:74
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::Split
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelperTemplates.h:35
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
filesystem.h
armarx::CMakePackageFinder::packageName
std::string packageName
Definition: CMakePackageFinder.h:207
StringHelpers.h
cxxopts::empty
bool empty(const std::string &s)
Definition: cxxopts.hpp:255
armarx::CMakePackageFinder::getArmarXCMakeTempDir
static std::string getArmarXCMakeTempDir()
return the path where the temporary cmake files are stored that are automically created by cmake.
Definition: CMakePackageFinder.cpp:609
SCRIPT_PATH
#define SCRIPT_PATH
Definition: CMakePackageFinder.cpp:55
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::CMakePackageFinder::getIncludePathList
std::vector< std::string > getIncludePathList() const
Return the include paths in a vector.
Definition: CMakePackageFinder.cpp:601
armarx::CMakeMutex
std::mutex & CMakeMutex()
Definition: CMakePackageFinder.cpp:147
armarx::CMakePackageFinder::getName
std::string getName() const
Returns the name of the given package.
Definition: CMakePackageFinder.cpp:480
armarx::CMakePackageFinder::ExecCommand
static std::string ExecCommand(std::string command, int &result, bool suppressStdErr=false)
Definition: CMakePackageFinder.cpp:412
armarx::CMakePackageFinder::getComponentExecutableNames
std::vector< std::string > getComponentExecutableNames() const
Definition: CMakePackageFinder.cpp:666
armarx::sharedMemorySegment
std::shared_ptr< boost::interprocess::managed_shared_memory > sharedMemorySegment
Definition: CMakePackageFinder.cpp:231
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::CMakePackageFinder::found
bool found
Definition: CMakePackageFinder.h:205
armarx::CMakePackageFinder::_ParseString
static bool _ParseString(const std::string &input, std::string &varName, std::string &content)
Definition: CMakePackageFinder.cpp:537
armarx::CMakePackageFinder::getVars
const std::map< std::string, std::string > & getVars() const
Definition: CMakePackageFinder.cpp:490
armarx::CMakePackageFinder::FindPackageIncludePathList
static std::vector< std::string > FindPackageIncludePathList(const std::string &packageName)
Static function to find the include path with cmake.
Definition: CMakePackageFinder.cpp:312
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
ExpressionException.h
CMakePackageFinder.h
CMakePackageFinderCache.h
armarx::CMakePackageFinder::_CreateSharedMutex
static void _CreateSharedMutex()
Definition: CMakePackageFinder.cpp:566
armarx::CMakePackageFinder::getDependencies
std::vector< std::string > getDependencies() const
Definition: CMakePackageFinder.cpp:507
armarx::readCMakeCache
bool readCMakeCache(const std::string &packageName, std::string &packageContent)
Definition: CMakePackageFinder.cpp:168
armarx::CMakePackageFinder::FindPackageLibs
static std::string FindPackageLibs(const std::string &packageName)
Definition: CMakePackageFinder.cpp:337
armarx::CMakePackageFinder::getIncludePaths
std::string getIncludePaths() const
Returns the include paths separated by semi-colons.
Definition: CMakePackageFinder.h:110
armarx::ends_with
bool ends_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:50
SharedMemoryExceptions.h
armarx::CMakePackageFinder::ReplaceCMakePackageFinderVars
static bool ReplaceCMakePackageFinderVars(std::string &string)
Replaces occurrences like $C{PACKAGE_NAME:VAR_NAME} with their CMakePackageFinder value.
Definition: CMakePackageFinder.cpp:630
armarx::CMakePackageFinderCache::GlobalCache
static CMakePackageFinderCache GlobalCache
Definition: CMakePackageFinderCache.h:19
armarx::CMakePackageFinder::getBuildDir
std::string getBuildDir() const
Definition: CMakePackageFinder.h:136
armarx::CMakeFileLock
const std::shared_ptr< boost::interprocess::file_lock > & CMakeFileLock()
Definition: CMakePackageFinder.cpp:139
armarx::ScopedFileLockPtr
std::shared_ptr< boost::interprocess::scoped_lock< boost::interprocess::file_lock > > ScopedFileLockPtr
Definition: CMakePackageFinder.cpp:153
armarx::CMakePackageFinder::FindPackageIncludePaths
static std::string FindPackageIncludePaths(const std::string &packageName)
Definition: CMakePackageFinder.cpp:372
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
armarx::ArmarXDataPath::getAbsolutePath
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
Definition: ArmarXDataPath.cpp:111
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::CMakePackageFinder::getDependencyPaths
std::map< std::string, std::string > getDependencyPaths() const
Definition: CMakePackageFinder.cpp:515
environ
char ** environ
ArmarXDataPath.h
armarx::updateCMakeCache
bool updateCMakeCache(const std::string &packageName, const std::string &packageContent)
Definition: CMakePackageFinder.cpp:202
armarx::memoryMutex
boost::interprocess::interprocess_upgradable_mutex * memoryMutex
Definition: CMakePackageFinder.cpp:230
simox
Definition: Impl.cpp:40
armarx::CMakePackageFinder::extractVariables
std::vector< std::string > extractVariables(const std::string &cmakeVarString)
Definition: CMakePackageFinder.cpp:572
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::getHomeDir
std::string getHomeDir()
Definition: CMakePackageFinder.cpp:63
armarx::CMakePackageFinder::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.
Definition: CMakePackageFinder.cpp:236
armarx::CreateAndCheckFileLock
std::shared_ptr< boost::interprocess::file_lock > CreateAndCheckFileLock(const std::string &name)
Definition: CMakePackageFinder.cpp:118
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:36