CMakePackageFinderCache.cpp
Go to the documentation of this file.
2
3namespace armarx
4{
6
8 packageFinders(s.packageFinders), timeout(s.timeout)
9 {
10 }
11
12 CMakePackageFinderCache::CMakePackageFinderCache(IceUtil::Time timeout) : timeout(timeout)
13 {
14 }
15
17 CMakePackageFinderCache::findPackage(const std::string& packageName,
18 const std::filesystem::path& packagePath,
19 bool suppressStdErr,
20 bool usePackagePathOnlyAsHint)
21 {
22 std::unique_lock lock(mutex);
23 auto it = packageFinders.find(packageName);
24 if (it != packageFinders.end())
25 {
26 if ((IceUtil::Time::now() - it->second.first) > timeout)
27 {
28 it->second.second = CMakePackageFinder(
29 packageName, packagePath, suppressStdErr, usePackagePathOnlyAsHint);
30 it->second.first = IceUtil::Time::now();
31 }
32 return it->second.second;
33 }
34 else
35 {
36 auto insertion = packageFinders.insert(std::make_pair(
37 packageName,
38 std::make_pair(IceUtil::Time::now(), CMakePackageFinder(packageName))));
39 return insertion.first->second.second;
40 }
41 }
42} // namespace armarx
const CMakePackageFinder & findPackage(const std::string &packageName, const std::filesystem::path &packagePath="", bool suppressStdErr=false, bool usePackagePathOnlyAsHint=false)
static CMakePackageFinderCache GlobalCache
CMakePackageFinderCache(const CMakePackageFinderCache &s)
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
This file offers overloads of toIce() and fromIce() functions for STL container types.