diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-06-08 15:27:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-06-09 15:02:25 (GMT) |
commit | 3e5b609547750f0498b6ca924fb70379457653da (patch) | |
tree | 57545b9d67b5681175b1c8f3264fc31ef449496b /Source/cmScanDepFormat.cxx | |
parent | aab9a5fc3e60db247c922f14420b088d9a983ff2 (diff) | |
download | CMake-3e5b609547750f0498b6ca924fb70379457653da.zip CMake-3e5b609547750f0498b6ca924fb70379457653da.tar.gz CMake-3e5b609547750f0498b6ca924fb70379457653da.tar.bz2 |
cmScanDepFormat: P1689R4: Make work-directory optional
Diffstat (limited to 'Source/cmScanDepFormat.cxx')
-rw-r--r-- | Source/cmScanDepFormat.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/cmScanDepFormat.cxx b/Source/cmScanDepFormat.cxx index d75a750..a40a552 100644 --- a/Source/cmScanDepFormat.cxx +++ b/Source/cmScanDepFormat.cxx @@ -5,6 +5,9 @@ #include <cctype> #include <cstdio> +#include <utility> + +#include <cm/optional> #include <cm3p/json/reader.h> #include <cm3p/json/value.h> @@ -69,8 +72,9 @@ static Json::Value EncodeFilename(std::string const& path) return false; \ } \ \ - if (!work_directory.empty() && !cmSystemTools::FileIsFullPath(res)) { \ - res = cmStrCat(work_directory, '/', res); \ + if (work_directory && !work_directory->empty() && \ + !cmSystemTools::FileIsFullPath(res)) { \ + res = cmStrCat(*work_directory, '/', res); \ } \ } while (0) @@ -106,10 +110,12 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp, } for (auto const& rule : rules) { - std::string work_directory; + cm::optional<std::string> work_directory; Json::Value const& workdir = rule["work-directory"]; if (workdir.isString()) { - PARSE_BLOB(workdir, work_directory); + std::string wd; + PARSE_BLOB(workdir, wd); + work_directory = std::move(wd); } else if (!workdir.isNull()) { cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ", arg_pp, |