diff options
author | Brad King <brad.king@kitware.com> | 2020-07-10 10:43:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-07-10 10:45:09 (GMT) |
commit | a5064f6e656f3c83c5aa78af67740365f08236fb (patch) | |
tree | 4c10ffe5c3743b8576218f82c1efd2e1a312ca96 /Source | |
parent | bf3a1e9a9b51cd6116d416148abfec2765cdef10 (diff) | |
parent | 961ee62faaf63cbd72724a4e9c039352ed44dad4 (diff) | |
download | CMake-a5064f6e656f3c83c5aa78af67740365f08236fb.zip CMake-a5064f6e656f3c83c5aa78af67740365f08236fb.tar.gz CMake-a5064f6e656f3c83c5aa78af67740365f08236fb.tar.bz2 |
Merge topic 'source_file_both_props'
961ee62faa Help: Update get_property and get_source_file_property docs
1235f2d747 set_property: Allow both DIRECTORY and TARGET_DIRECTORY together
177052d6b8 set_property: Fix name of TARGET_DIRECTORY option in error messages
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4994
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmSetPropertyCommand.cxx | 19 | ||||
-rw-r--r-- | Source/cmSetSourceFilesPropertiesCommand.cxx | 39 |
2 files changed, 37 insertions, 21 deletions
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 07cb7c9..51509fd 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -96,12 +96,14 @@ bool HandleSourceFileDirectoryScopes( } directory_makefiles.push_back(dir_mf); } - } else if (!source_file_target_directories.empty()) { + } + + if (!source_file_target_directories.empty()) { for (const std::string& target_name : source_file_target_directories) { cmTarget* target = current_dir_mf->FindTargetToUse(target_name); if (!target) { status.SetError(cmStrCat( - "given non-existent target for DIRECTORY_TARGET ", target_name)); + "given non-existent target for TARGET_DIRECTORY ", target_name)); return false; } cmProp target_source_dir = target->GetProperty("SOURCE_DIR"); @@ -110,7 +112,10 @@ bool HandleSourceFileDirectoryScopes( *target_source_dir); directory_makefiles.push_back(target_dir_mf); } - } else { + } + + if (source_file_directories.empty() && + source_file_target_directories.empty()) { directory_makefiles.push_back(current_dir_mf); } return true; @@ -271,12 +276,12 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args, appendMode = true; remove = false; appendAsString = true; - } else if (doing == DoingNames && scope == cmProperty::SOURCE_FILE && - arg == "DIRECTORY") { + } else if (doing != DoingProperty && doing != DoingValues && + scope == cmProperty::SOURCE_FILE && arg == "DIRECTORY") { doing = DoingSourceDirectory; source_file_directory_option_enabled = true; - } else if (doing == DoingNames && scope == cmProperty::SOURCE_FILE && - arg == "TARGET_DIRECTORY") { + } else if (doing != DoingProperty && doing != DoingValues && + scope == cmProperty::SOURCE_FILE && arg == "TARGET_DIRECTORY") { doing = DoingSourceTargetDirectory; source_file_target_option_enabled = true; } else if (doing == DoingNames) { diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 3135a06..c1b0c28 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -35,11 +35,11 @@ bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args, "OBJECT_DEPENDS", "PROPERTIES", "DIRECTORY", "TARGET_DIRECTORY" }; - auto isNotAPropertyKeyword = + auto isAPropertyKeyword = [](const std::vector<std::string>::const_iterator& arg_it) { - return std::all_of( + return std::any_of( std::begin(prop_names), std::end(prop_names), - [&arg_it](cm::string_view prop_name) { return *arg_it != prop_name; }); + [&arg_it](cm::string_view prop_name) { return *arg_it == prop_name; }); }; auto options_begin = std::find_first_of( @@ -53,21 +53,32 @@ bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args, bool source_file_target_option_enabled = false; std::vector<cmMakefile*> source_file_directory_makefiles; - if (options_it != args.end() && *options_it == "DIRECTORY") { - source_file_directory_option_enabled = true; - ++options_it; - while (options_it != args.end() && isNotAPropertyKeyword(options_it)) { + enum Doing + { + DoingNone, + DoingSourceDirectory, + DoingSourceTargetDirectory + }; + Doing doing = DoingNone; + for (; options_it != args.end(); ++options_it) { + if (*options_it == "DIRECTORY") { + doing = DoingSourceDirectory; + source_file_directory_option_enabled = true; + } else if (*options_it == "TARGET_DIRECTORY") { + doing = DoingSourceTargetDirectory; + source_file_target_option_enabled = true; + } else if (isAPropertyKeyword(options_it)) { + break; + } else if (doing == DoingSourceDirectory) { source_file_directories.push_back(*options_it); - ++options_it; - } - } else if (options_it != args.end() && *options_it == "TARGET_DIRECTORY") { - source_file_target_option_enabled = true; - ++options_it; - while (options_it != args.end() && isNotAPropertyKeyword(options_it)) { + } else if (doing == DoingSourceTargetDirectory) { source_file_target_directories.push_back(*options_it); - ++options_it; + } else { + status.SetError( + cmStrCat("given invalid argument \"", *options_it, "\".")); } } + const auto props_begin = options_it; bool file_scopes_handled = |