mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 20:00:38 -06:00
get_property(TEST): Add DIRECTORY option
This commit is contained in:
@@ -12,7 +12,8 @@ Get a property.
|
||||
SOURCE <source>
|
||||
[DIRECTORY <dir> | TARGET_DIRECTORY <target>] |
|
||||
INSTALL <file> |
|
||||
TEST <test> |
|
||||
TEST <test>
|
||||
[DIRECTORY <dir>] |
|
||||
CACHE <entry> |
|
||||
VARIABLE >
|
||||
PROPERTY <name>
|
||||
@@ -73,6 +74,16 @@ It must be one of the following:
|
||||
Scope must name one existing test.
|
||||
See also the :command:`get_test_property` command.
|
||||
|
||||
.. versionadded:: 3.28
|
||||
Directory scope can be overridden with the following sub-option:
|
||||
|
||||
``DIRECTORY <dir>``
|
||||
The test property will be read from the ``<dir>`` directory's
|
||||
scope. CMake must already know about the directory, either by having added
|
||||
it through a call to :command:`add_subdirectory` or ``<dir>`` being the top
|
||||
level directory. Relative paths are treated as relative to the current
|
||||
source directory. ``<dir>`` may reference a binary directory.
|
||||
|
||||
``CACHE``
|
||||
Scope must name one cache entry.
|
||||
|
||||
|
||||
@@ -7,3 +7,6 @@ test-properties-directory
|
||||
* The :command:`set_tests_properties` command gained a ``DIRECTORY``
|
||||
sub-option, which allows you to set properties on tests in other
|
||||
directories.
|
||||
* The ``TEST`` mode of the :command:`get_property` command gained a
|
||||
``DIRECTORY`` sub-option, which allows you to get properties on tests in
|
||||
other directories.
|
||||
|
||||
@@ -49,7 +49,8 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
|
||||
bool source_file_paths_should_be_absolute);
|
||||
bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
|
||||
OutType infoType, const std::string& variable,
|
||||
const std::string& propertyName);
|
||||
const std::string& propertyName,
|
||||
cmMakefile& directory_makefile);
|
||||
bool HandleVariableMode(cmExecutionStatus& status, const std::string& name,
|
||||
OutType infoType, const std::string& variable,
|
||||
const std::string& propertyName);
|
||||
@@ -81,6 +82,9 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
|
||||
bool source_file_directory_option_enabled = false;
|
||||
bool source_file_target_option_enabled = false;
|
||||
|
||||
std::string test_directory;
|
||||
bool test_directory_option_enabled = false;
|
||||
|
||||
// Get the scope from which to get the property.
|
||||
cmProperty::ScopeType scope;
|
||||
if (args[1] == "GLOBAL") {
|
||||
@@ -116,7 +120,8 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
|
||||
DoingProperty,
|
||||
DoingType,
|
||||
DoingSourceDirectory,
|
||||
DoingSourceTargetDirectory
|
||||
DoingSourceTargetDirectory,
|
||||
DoingTestDirectory,
|
||||
};
|
||||
Doing doing = DoingName;
|
||||
for (unsigned int i = 2; i < args.size(); ++i) {
|
||||
@@ -145,12 +150,19 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
|
||||
args[i] == "TARGET_DIRECTORY") {
|
||||
doing = DoingSourceTargetDirectory;
|
||||
source_file_target_option_enabled = true;
|
||||
} else if (doing == DoingNone && scope == cmProperty::TEST &&
|
||||
args[i] == "DIRECTORY") {
|
||||
doing = DoingTestDirectory;
|
||||
test_directory_option_enabled = true;
|
||||
} else if (doing == DoingSourceDirectory) {
|
||||
source_file_directories.push_back(args[i]);
|
||||
doing = DoingNone;
|
||||
} else if (doing == DoingSourceTargetDirectory) {
|
||||
source_file_target_directories.push_back(args[i]);
|
||||
doing = DoingNone;
|
||||
} else if (doing == DoingTestDirectory) {
|
||||
test_directory = args[i];
|
||||
doing = DoingNone;
|
||||
} else if (doing == DoingProperty) {
|
||||
doing = DoingNone;
|
||||
propertyName = args[i];
|
||||
@@ -167,12 +179,17 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
std::vector<cmMakefile*> source_file_directory_makefiles;
|
||||
bool file_scopes_handled =
|
||||
bool source_file_scopes_handled =
|
||||
SetPropertyCommand::HandleAndValidateSourceFileDirectoryScopes(
|
||||
status, source_file_directory_option_enabled,
|
||||
source_file_target_option_enabled, source_file_directories,
|
||||
source_file_target_directories, source_file_directory_makefiles);
|
||||
if (!file_scopes_handled) {
|
||||
cmMakefile* test_directory_makefile;
|
||||
bool test_scopes_handled =
|
||||
SetPropertyCommand::HandleAndValidateTestDirectoryScopes(
|
||||
status, test_directory_option_enabled, test_directory,
|
||||
test_directory_makefile);
|
||||
if (!(source_file_scopes_handled && test_scopes_handled)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,7 +248,8 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
|
||||
directory_scope_mf,
|
||||
source_file_paths_should_be_absolute);
|
||||
case cmProperty::TEST:
|
||||
return HandleTestMode(status, name, infoType, variable, propertyName);
|
||||
return HandleTestMode(status, name, infoType, variable, propertyName,
|
||||
*test_directory_makefile);
|
||||
case cmProperty::VARIABLE:
|
||||
return HandleVariableMode(status, name, infoType, variable,
|
||||
propertyName);
|
||||
@@ -404,7 +422,7 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
|
||||
|
||||
bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
|
||||
OutType infoType, const std::string& variable,
|
||||
const std::string& propertyName)
|
||||
const std::string& propertyName, cmMakefile& test_makefile)
|
||||
{
|
||||
if (name.empty()) {
|
||||
status.SetError("not given name for TEST scope.");
|
||||
@@ -412,7 +430,7 @@ bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
|
||||
}
|
||||
|
||||
// Loop over all tests looking for matching names.
|
||||
if (cmTest* test = status.GetMakefile().GetTest(name)) {
|
||||
if (cmTest* test = test_makefile.GetTest(name)) {
|
||||
return StoreResult(infoType, status.GetMakefile(), variable,
|
||||
test->GetProperty(propertyName));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user