Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Brad King
CMake
Commits
e6055284
Commit
e6055284
authored
Jun 11, 2013
by
Stephen Kelly
Browse files
Add generator expressions for version comparision.
parent
48bb48e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Source/cmDocumentGeneratorExpressions.h
View file @
e6055284
...
...
@@ -48,6 +48,12 @@
"used.\n" \
" $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX " \
"compiler matches comp, otherwise '0'.\n" \
" $<VERSION_GREATER:v1,v2> = '1' if v1 is a version greater than " \
"v2, else '0'.\n" \
" $<VERSION_LESS:v1,v2> = '1' if v1 is a version less than v2, " \
"else '0'.\n" \
" $<VERSION_EQUAL:v1,v2> = '1' if v1 is the same version as v2, " \
"else '0'.\n" \
" $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n" \
" $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n" \
" $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)\n" \
...
...
Source/cmGeneratorExpressionEvaluator.cxx
View file @
e6055284
...
...
@@ -344,6 +344,60 @@ static const struct CXXCompilerIdNode : public CompilerIdNode
}
}
cxxCompilerIdNode
;
//----------------------------------------------------------------------------
static
const
struct
VersionGreaterNode
:
public
cmGeneratorExpressionNode
{
VersionGreaterNode
()
{}
virtual
int
NumExpectedParameters
()
const
{
return
2
;
}
std
::
string
Evaluate
(
const
std
::
vector
<
std
::
string
>
&
parameters
,
cmGeneratorExpressionContext
*
,
const
GeneratorExpressionContent
*
,
cmGeneratorExpressionDAGChecker
*
)
const
{
return
cmSystemTools
::
VersionCompare
(
cmSystemTools
::
OP_GREATER
,
parameters
.
front
().
c_str
(),
parameters
[
1
].
c_str
())
?
"1"
:
"0"
;
}
}
versionGreaterNode
;
//----------------------------------------------------------------------------
static
const
struct
VersionLessNode
:
public
cmGeneratorExpressionNode
{
VersionLessNode
()
{}
virtual
int
NumExpectedParameters
()
const
{
return
2
;
}
std
::
string
Evaluate
(
const
std
::
vector
<
std
::
string
>
&
parameters
,
cmGeneratorExpressionContext
*
,
const
GeneratorExpressionContent
*
,
cmGeneratorExpressionDAGChecker
*
)
const
{
return
cmSystemTools
::
VersionCompare
(
cmSystemTools
::
OP_LESS
,
parameters
.
front
().
c_str
(),
parameters
[
1
].
c_str
())
?
"1"
:
"0"
;
}
}
versionLessNode
;
//----------------------------------------------------------------------------
static
const
struct
VersionEqualNode
:
public
cmGeneratorExpressionNode
{
VersionEqualNode
()
{}
virtual
int
NumExpectedParameters
()
const
{
return
2
;
}
std
::
string
Evaluate
(
const
std
::
vector
<
std
::
string
>
&
parameters
,
cmGeneratorExpressionContext
*
,
const
GeneratorExpressionContent
*
,
cmGeneratorExpressionDAGChecker
*
)
const
{
return
cmSystemTools
::
VersionCompare
(
cmSystemTools
::
OP_EQUAL
,
parameters
.
front
().
c_str
(),
parameters
[
1
].
c_str
())
?
"1"
:
"0"
;
}
}
versionEqualNode
;
//----------------------------------------------------------------------------
static
const
struct
ConfigurationNode
:
public
cmGeneratorExpressionNode
{
...
...
@@ -1169,6 +1223,12 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return
&
cCompilerIdNode
;
else
if
(
identifier
==
"CXX_COMPILER_ID"
)
return
&
cxxCompilerIdNode
;
else
if
(
identifier
==
"VERSION_GREATER"
)
return
&
versionGreaterNode
;
else
if
(
identifier
==
"VERSION_LESS"
)
return
&
versionLessNode
;
else
if
(
identifier
==
"VERSION_EQUAL"
)
return
&
versionEqualNode
;
else
if
(
identifier
==
"CONFIGURATION"
)
return
&
configurationNode
;
else
if
(
identifier
==
"CONFIG"
)
...
...
Tests/GeneratorExpression/CMakeLists.txt
View file @
e6055284
...
...
@@ -130,6 +130,12 @@ add_custom_target(check-part2 ALL
-Dtest_arbitrary_content_comma_8=$<1:a,,b>
-Dtest_arbitrary_content_comma_9=$<1:a,,b,,>
-Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,>
-Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1>
-Dtest_version_greater_2=$<VERSION_GREATER:1.1.1,1.0>
-Dtest_version_less_1=$<VERSION_LESS:1.1.1,1.0>
-Dtest_version_less_2=$<VERSION_LESS:1.0,1.1.1>
-Dtest_version_equal_1=$<VERSION_EQUAL:1.0.1,1.1>
-Dtest_version_equal_2=$<VERSION_EQUAL:1.1,1.1>
-P
${
CMAKE_CURRENT_SOURCE_DIR
}
/check-part2.cmake
COMMAND
${
CMAKE_COMMAND
}
-E echo
"check done (part 2 of 2)"
VERBATIM
...
...
Tests/GeneratorExpression/check-part2.cmake
View file @
e6055284
...
...
@@ -44,3 +44,9 @@ check(test_arbitrary_content_comma_7 ",,a")
check
(
test_arbitrary_content_comma_8
"a,,b"
)
check
(
test_arbitrary_content_comma_9
"a,,b,,"
)
check
(
test_arbitrary_content_comma_10
",,a,,b,,"
)
check
(
test_version_greater_1
"0"
)
check
(
test_version_greater_2
"1"
)
check
(
test_version_less_1
"0"
)
check
(
test_version_less_2
"1"
)
check
(
test_version_equal_1
"0"
)
check
(
test_version_equal_2
"1"
)
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