Genex: Add the PLATFORM_ID expression.
This commit is contained in:
parent
150bc7da3d
commit
dcc00ece4b
|
@ -40,6 +40,9 @@
|
|||
"is exported using export(), or when the target is used by another " \
|
||||
"target in the same buildsystem. Expands to the empty string " \
|
||||
"otherwise.\n" \
|
||||
" $<PLATFORM_ID> = The CMake-id of the platform " \
|
||||
" $<PLATFORM_ID:comp> = '1' if the The CMake-id of the " \
|
||||
"platform matches comp, otherwise '0'.\n" \
|
||||
" $<C_COMPILER_ID> = The CMake-id of the C compiler " \
|
||||
"used.\n" \
|
||||
" $<C_COMPILER_ID:comp> = '1' if the CMake-id of the C " \
|
||||
|
|
|
@ -437,6 +437,39 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode
|
|||
} cxxCompilerVersionNode;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct PlatformIdNode : public cmGeneratorExpressionNode
|
||||
{
|
||||
PlatformIdNode() {}
|
||||
|
||||
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
|
||||
|
||||
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||
cmGeneratorExpressionContext *context,
|
||||
const GeneratorExpressionContent *,
|
||||
cmGeneratorExpressionDAGChecker *) const
|
||||
{
|
||||
const char *platformId = context->Makefile ?
|
||||
context->Makefile->GetSafeDefinition(
|
||||
"CMAKE_SYSTEM_NAME") : "";
|
||||
if (parameters.size() == 0)
|
||||
{
|
||||
return platformId ? platformId : "";
|
||||
}
|
||||
|
||||
if (!platformId)
|
||||
{
|
||||
return parameters.front().empty() ? "1" : "0";
|
||||
}
|
||||
|
||||
if (cmsysString_strcasecmp(parameters.begin()->c_str(), platformId) == 0)
|
||||
{
|
||||
return "1";
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
} platformIdNode;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const struct VersionGreaterNode : public cmGeneratorExpressionNode
|
||||
{
|
||||
|
@ -1355,6 +1388,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
|
|||
return &cCompilerVersionNode;
|
||||
else if (identifier == "CXX_COMPILER_VERSION")
|
||||
return &cxxCompilerVersionNode;
|
||||
else if (identifier == "PLATFORM_ID")
|
||||
return &platformIdNode;
|
||||
else if (identifier == "CONFIGURATION")
|
||||
return &configurationNode;
|
||||
else if (identifier == "CONFIG")
|
||||
|
|
|
@ -186,6 +186,11 @@ add_custom_target(check-part3 ALL
|
|||
-Dtest_alias_target_name=$<STREQUAL:$<TARGET_PROPERTY:Alias::SomeLib,NAME>,$<TARGET_PROPERTY:empty1,NAME>>
|
||||
-Dtest_early_termination_1=$<$<1:>:
|
||||
-Dtest_early_termination_2=$<$<1:>:,
|
||||
-Dsystem_name=${CMAKE_HOST_SYSTEM_NAME}
|
||||
-Dtest_platform_id=$<PLATFORM_ID>
|
||||
-Dtest_platform_id_Linux=$<PLATFORM_ID:Linux>
|
||||
-Dtest_platform_id_Windows=$<PLATFORM_ID:Windows>
|
||||
-Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin>
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
|
||||
VERBATIM
|
||||
|
|
|
@ -26,3 +26,11 @@ check(test_alias_file_lib "1")
|
|||
check(test_alias_target_name "1")
|
||||
check(test_early_termination_1 "$<:")
|
||||
check(test_early_termination_2 "$<:,")
|
||||
check(test_platform_id "${system_name}")
|
||||
foreach(system Linux Windows Darwin)
|
||||
if(system_name STREQUAL system)
|
||||
check(test_platform_id_${system} 1)
|
||||
else()
|
||||
check(test_platform_id_${system} 0)
|
||||
endif()
|
||||
endforeach()
|
||||
|
|
Loading…
Reference in New Issue