mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-04 04:03:22 +03:00
1 parent
b1b85b8cf7
commit
26690d7678
14 files changed
+90
No files matched your search
@@ -1449,6 +1449,19 @@ Configuration Expressions
|
||||
in ``...`` are evaluated using the custom command's "command config".
|
||||
With other generators, the content of ``...`` is evaluated normally.
|
||||
|
||||
Global Expressions
|
||||
------------------
|
||||
|
||||
Global Properties
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. genex:: $<GLOBAL_PROPERTY:prop>
|
||||
|
||||
.. versionadded:: 4.5
|
||||
|
||||
Value of the global property ``prop``, or empty if
|
||||
the property is not set.
|
||||
|
||||
Rule-Dependent Expressions
|
||||
--------------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
GenEx-GLOBAL_PROPERTY
|
||||
---------------------
|
||||
|
||||
* CMake gains the :genex:`GLOBAL_PROPERTY` generator expression to query
|
||||
global properties.
|
||||
@@ -4080,6 +4080,31 @@ static const struct DeviceLinkNode : public cmGeneratorExpressionNode
|
||||
}
|
||||
} deviceLinkNode;
|
||||
|
||||
static const struct GlobalPropertyNode : public cmGeneratorExpressionNode
|
||||
{
|
||||
GlobalPropertyNode() {} // NOLINT(modernize-use-equals-default)
|
||||
|
||||
// This node handles errors on parameter count itself.
|
||||
int NumExpectedParameters() const override { return 1; }
|
||||
|
||||
std::string Evaluate(
|
||||
std::vector<std::string> const& parameters, cm::GenEx::Evaluation* eval,
|
||||
GeneratorExpressionContent const* content,
|
||||
cmGeneratorExpressionDAGChecker* /*dagCheckerParent*/) const override
|
||||
{
|
||||
auto const& propertyName = parameters[0];
|
||||
|
||||
if (propertyName.empty()) {
|
||||
reportError(eval, content->GetOriginalExpression(),
|
||||
"$<GLOBAL_PROPERTY:property> expression requires a "
|
||||
"non-empty property name.");
|
||||
return std::string{};
|
||||
}
|
||||
cmake* cm = eval->Context.LG->GetCMakeInstance();
|
||||
return cm->GetState()->GetGlobalProperty(propertyName);
|
||||
}
|
||||
} globalPropertyNode;
|
||||
|
||||
namespace {
|
||||
bool GetFileSet(std::vector<std::string> const& parameters,
|
||||
cm::GenEx::Evaluation* eval,
|
||||
@@ -6538,6 +6563,7 @@ cmGeneratorExpressionNode const* cmGeneratorExpressionNode::GetNode(
|
||||
{ "COMMA", &commaNode },
|
||||
{ "SEMICOLON", &semicolonNode },
|
||||
{ "QUOTE", "eNode },
|
||||
{ "GLOBAL_PROPERTY", &globalPropertyNode },
|
||||
{ "RULE_PROPERTY", &rulePropertyNode },
|
||||
{ "SOURCE_EXISTS", &sourceExistsNode },
|
||||
{ "SOURCE_PROPERTY", &sourcePropertyNode },
|
||||
|
||||
@@ -573,6 +573,7 @@ add_RunCMake_test(GenEx-LINK_GROUP)
|
||||
add_RunCMake_test(GenEx-TARGET_FILE -DLINKER_SUPPORTS_PDB=${LINKER_SUPPORTS_PDB})
|
||||
add_RunCMake_test(GenEx-TARGET_IMPORT_FILE)
|
||||
add_RunCMake_test(GenEx-GENEX_EVAL)
|
||||
add_RunCMake_test(GenEx-GLOBAL_PROPERTY)
|
||||
add_RunCMake_test(GenEx-RULE_PROPERTY)
|
||||
add_RunCMake_test(GenEx-SOURCE_EXISTS)
|
||||
add_RunCMake_test(GenEx-SOURCE_PROPERTY)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 4.0...4.4)
|
||||
|
||||
project(${RunCMake_TEST} NONE)
|
||||
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
@@ -0,0 +1,5 @@
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/GLOBAL_PROPERTY-generated.txt" content)
|
||||
|
||||
if(NOT content MATCHES "ENABLED_LANGUAGES=C;CXX" OR NOT content MATCHES "DEBUG_CONFIGURATIONS=Debug;Foo")
|
||||
set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[ENABLED_LANGUAGES=C;CXX\nDEBUG_CONFIGURATIONS=Debug;Foo]]")
|
||||
endif()
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
enable_language(C)
|
||||
enable_language(CXX)
|
||||
|
||||
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug Foo)
|
||||
|
||||
file(GENERATE OUTPUT GLOBAL_PROPERTY-generated.txt CONTENT "ENABLED_LANGUAGES=$<GLOBAL_PROPERTY:ENABLED_LANGUAGES>\nDEBUG_CONFIGURATIONS=$<GLOBAL_PROPERTY:DEBUG_CONFIGURATIONS>\n")
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(no-arguments)
|
||||
run_cmake(no-property)
|
||||
run_cmake(GLOBAL_PROPERTY)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,8 @@
|
||||
CMake Error at no-arguments\.cmake:[0-9]+ \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<GLOBAL_PROPERTY>
|
||||
|
||||
\$<GLOBAL_PROPERTY> expression requires exactly one parameter\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
file(GENERATE OUTPUT result.txt CONTENT "$<GLOBAL_PROPERTY>")
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,8 @@
|
||||
CMake Error at no-property\.cmake:[0-9]+ \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<GLOBAL_PROPERTY:>
|
||||
|
||||
\$<GLOBAL_PROPERTY:property> expression requires a non-empty property name\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
file(GENERATE OUTPUT result.txt CONTENT "$<GLOBAL_PROPERTY:>")
|
||||
Reference in new issue
Block a user