Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
b6036d10
Commit
b6036d10
authored
Jan 08, 2013
by
Stephen Kelly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract the AddTargetNamespace method.
parent
cb1afbf4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
95 deletions
+52
-95
Source/cmExportFileGenerator.cxx
Source/cmExportFileGenerator.cxx
+48
-95
Source/cmExportFileGenerator.h
Source/cmExportFileGenerator.h
+4
-0
No files found.
Source/cmExportFileGenerator.cxx
View file @
b6036d10
...
...
@@ -183,6 +183,41 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target,
}
}
//----------------------------------------------------------------------------
bool
cmExportFileGenerator
::
AddTargetNamespace
(
std
::
string
&
input
,
cmTarget
*
target
,
std
::
vector
<
std
::
string
>
&
missingTargets
)
{
cmMakefile
*
mf
=
target
->
GetMakefile
();
cmTarget
*
tgt
=
mf
->
FindTargetToUse
(
input
.
c_str
());
if
(
!
tgt
)
{
return
false
;
}
if
(
tgt
->
IsImported
())
{
return
true
;
}
if
(
this
->
ExportedTargets
.
find
(
tgt
)
!=
this
->
ExportedTargets
.
end
())
{
input
=
this
->
Namespace
+
input
;
}
else
{
std
::
string
namespacedTarget
;
this
->
HandleMissingTarget
(
namespacedTarget
,
missingTargets
,
mf
,
target
,
tgt
);
if
(
!
namespacedTarget
.
empty
())
{
input
=
namespacedTarget
;
}
}
return
true
;
}
//----------------------------------------------------------------------------
void
cmExportFileGenerator
::
ResolveTargetsInGeneratorExpressions
(
...
...
@@ -212,45 +247,17 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
continue
;
}
const
std
::
string
targetName
=
input
.
substr
(
nameStartPos
,
std
::
string
targetName
=
input
.
substr
(
nameStartPos
,
commaPos
-
nameStartPos
);
pos
=
nameStartPos
;
// We're not going to replace the entire expression,
// but only the target parameter.
if
(
cmTarget
*
tgt
=
mf
->
FindTargetToUse
(
targetName
.
c_str
()))
{
if
(
tgt
->
IsImported
())
{
pos
+=
targetName
.
size
();
}
else
if
(
this
->
ExportedTargets
.
find
(
tgt
)
!=
this
->
ExportedTargets
.
end
())
{
input
.
replace
(
pos
,
targetName
.
size
(),
this
->
Namespace
+
targetName
);
pos
+=
this
->
Namespace
.
size
()
+
targetName
.
size
();
}
else
{
std
::
string
namespacedTarget
;
this
->
HandleMissingTarget
(
namespacedTarget
,
missingTargets
,
mf
,
target
,
tgt
);
if
(
!
namespacedTarget
.
empty
())
{
input
.
replace
(
pos
,
targetName
.
size
(),
namespacedTarget
);
pos
+=
namespacedTarget
.
size
();
}
}
}
else
if
(
!
this
->
AddTargetNamespace
(
targetName
,
target
,
missingTargets
))
{
errorString
=
"$<TARGET_PROPERTY:"
+
targetName
+
",prop> requires "
"its first parameter to be a reachable target."
;
}
lastPos
=
pos
;
if
(
!
errorString
.
empty
())
{
break
;
}
input
.
replace
(
nameStartPos
,
commaPos
-
nameStartPos
,
targetName
);
lastPos
=
pos
+
targetName
.
size
();
}
if
(
!
errorString
.
empty
())
{
...
...
@@ -267,51 +274,24 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
if
(
endPos
==
input
.
npos
)
{
errorString
=
"$<TARGET_NAME:...> expression incomplete"
;
break
;
}
const
std
::
string
targetName
=
input
.
substr
(
nameStartPos
,
std
::
string
targetName
=
input
.
substr
(
nameStartPos
,
endPos
-
nameStartPos
);
if
(
targetName
.
find
(
"$<"
)
!=
input
.
npos
)
{
errorString
=
"$<TARGET_NAME:...> requires its parameter to be a "
"literal."
;
break
;
}
if
(
cmTarget
*
tgt
=
mf
->
FindTargetToUse
(
targetName
.
c_str
()))
{
if
(
tgt
->
IsImported
())
{
input
.
replace
(
pos
,
sizeof
(
"$<TARGET_NAME:"
)
+
targetName
.
size
(),
targetName
);
pos
+=
sizeof
(
"$<TARGET_NAME:"
)
+
targetName
.
size
();
}
else
if
(
this
->
ExportedTargets
.
find
(
tgt
)
!=
this
->
ExportedTargets
.
end
())
{
input
.
replace
(
pos
,
sizeof
(
"$<TARGET_NAME:"
)
+
targetName
.
size
(),
this
->
Namespace
+
targetName
);
pos
+=
sizeof
(
"$<TARGET_NAME:"
)
+
targetName
.
size
();
}
else
{
std
::
string
namespacedTarget
;
this
->
HandleMissingTarget
(
namespacedTarget
,
missingTargets
,
mf
,
target
,
tgt
);
if
(
!
namespacedTarget
.
empty
())
{
input
.
replace
(
pos
,
sizeof
(
"$<TARGET_NAME:"
)
+
targetName
.
size
(),
namespacedTarget
);
pos
+=
sizeof
(
"$<TARGET_NAME:"
)
+
targetName
.
size
();
}
}
}
else
if
(
!
this
->
AddTargetNamespace
(
targetName
,
target
,
missingTargets
))
{
errorString
=
"$<TARGET_NAME:...> requires its parameter to be a "
"reachable target."
;
}
lastPos
=
pos
;
if
(
!
errorString
.
empty
())
{
break
;
}
input
.
replace
(
pos
,
endPos
-
pos
+
1
,
targetName
);
lastPos
=
endPos
;
}
if
(
!
errorString
.
empty
())
{
...
...
@@ -397,9 +377,6 @@ cmExportFileGenerator
return
;
}
// Get the makefile in which to lookup target information.
cmMakefile
*
mf
=
target
->
GetMakefile
();
// Construct the property value.
std
::
string
link_libs
;
const
char
*
sep
=
""
;
...
...
@@ -410,33 +387,9 @@ cmExportFileGenerator
link_libs
+=
sep
;
sep
=
";"
;
// Append this entry.
if
(
cmTarget
*
tgt
=
mf
->
FindTargetToUse
(
li
->
c_str
()))
{
// This is a target.
if
(
tgt
->
IsImported
())
{
// The target is imported (and therefore is not in the
// export). Append the raw name.
link_libs
+=
*
li
;
}
else
if
(
this
->
ExportedTargets
.
find
(
tgt
)
!=
this
->
ExportedTargets
.
end
())
{
// The target is in the export. Append it with the export
// namespace.
link_libs
+=
this
->
Namespace
;
link_libs
+=
*
li
;
}
else
{
this
->
HandleMissingTarget
(
link_libs
,
missingTargets
,
mf
,
target
,
tgt
);
}
}
else
{
// Append the raw name.
link_libs
+=
*
li
;
}
std
::
string
temp
=
*
li
;
this
->
AddTargetNamespace
(
temp
,
target
,
missingTargets
);
link_libs
+=
temp
;
}
// Store the property.
...
...
Source/cmExportFileGenerator.h
View file @
b6036d10
...
...
@@ -128,6 +128,10 @@ private:
cmGeneratorExpression
::
PreprocessContext
,
ImportPropertyMap
&
properties
,
std
::
vector
<
std
::
string
>
&
missingTargets
);
bool
AddTargetNamespace
(
std
::
string
&
input
,
cmTarget
*
target
,
std
::
vector
<
std
::
string
>
&
missingTargets
);
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment