Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ArmarXCore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
ArmarXCore
Commits
6c67f887
Commit
6c67f887
authored
2 years ago
by
Fabian Reister
Browse files
Options
Downloads
Patches
Plain Diff
use environment variables to discover cmake packages
parent
2678e636
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!221
CMake package finder: use environment variables instead of global cmake registry
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/ArmarXCore/core/system/cmake/CMakePackageFinder.cpp
+34
-12
34 additions, 12 deletions
source/ArmarXCore/core/system/cmake/CMakePackageFinder.cpp
with
34 additions
and
12 deletions
source/ArmarXCore/core/system/cmake/CMakePackageFinder.cpp
+
34
−
12
View file @
6c67f887
...
...
@@ -50,10 +50,14 @@
#include
<memory>
#include
<ctime>
#include
<mutex>
#include
<cstdlib>
#define SCRIPT_PATH "ArmarXCore/core/system/cmake/FindPackageX.cmake"
#define CACHE_PATH "/ArmarXCMakeCache_" + (getenv("USER")?getenv("USER"):"DUMMY_USER")
extern
char
**
environ
;
namespace
armarx
{
std
::
string
getHomeDir
()
...
...
@@ -435,23 +439,41 @@ namespace armarx
{
std
::
vector
<
std
::
string
>
result
;
using
namespace
std
::
filesystem
;
auto
home
=
getHomeDir
();
if
(
!
home
.
empty
())
{
path
p
=
path
{
home
}
/
".cmake"
/
"packages"
;
if
(
is_directory
(
p
))
char
**
env
;
env
=
environ
;
for
(;
*
env
;
++
env
)
{
const
std
::
string
envVar
(
*
env
);
ARMARX_DEBUG
<<
"Retrieved environment variable "
<<
envVar
;
const
std
::
vector
<
std
::
string
>
elements
=
simox
::
alg
::
split
(
envVar
,
"="
);
if
(
not
(
elements
.
size
()
==
2
))
{
for
(
const
path
&
entry
:
boost
::
make_iterator_range
(
directory_iterator
(
p
),
{}))
continue
;
}
const
std
::
string
&
envVarName
=
elements
.
front
();
const
std
::
string
&
envVarValue
=
elements
.
back
();
if
(
simox
::
alg
::
ends_with
(
envVarName
,
"_DIR"
))
{
const
std
::
string
packageName
=
simox
::
alg
::
remove_suffix
(
envVarName
,
"_DIR"
);
auto
pckFinder
=
CMakePackageFinder
{
packageName
,
envVarValue
,
true
};
ARMARX_DEBUG
<<
"Package name: "
<<
packageName
;
ARMARX_DEBUG
<<
"Path: "
<<
envVarValue
;
// check if this is really a package
if
(
pckFinder
.
packageFound
()
&&
!
pckFinder
.
getBuildDir
().
empty
())
{
const
std
::
string
pkg
=
entry
.
filename
().
string
();
auto
pckFinder
=
CMakePackageFinder
{
pkg
,
""
,
true
};
if
(
pckFinder
.
packageFound
()
&&
!
pckFinder
.
getBuildDir
().
empty
())
{
result
.
push_back
(
pkg
);
}
ARMARX_VERBOSE
<<
"Found package "
<<
packageName
;
result
.
push_back
(
packageName
);
}
}
}
return
result
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment