summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-18 11:16:12 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-03-18 11:16:23 (GMT)
commitb782d9e124aeea0a7c9511120df740cf97c818d2 (patch)
tree8746ce9f166c23d4001b1f8563ecf0f425d81bd5
parent736964d94f020524ff5d89de80febce26724395d (diff)
parentb44ad7992a2a377cc48ba1b7f666d863dbac34f3 (diff)
downloadCMake-b782d9e124aeea0a7c9511120df740cf97c818d2.zip
CMake-b782d9e124aeea0a7c9511120df740cf97c818d2.tar.gz
CMake-b782d9e124aeea0a7c9511120df740cf97c818d2.tar.bz2
Merge topic 'always_prefer_last_source_dir' into release-3.23
b44ad7992a cmake: Always prefer the last source directory provided Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7084
-rw-r--r--Source/cmake.cxx19
-rw-r--r--Source/cmake.h11
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake2
3 files changed, 8 insertions, 24 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f9e2d6e..7de488b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -819,7 +819,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::string path = cmSystemTools::CollapseFullPath(value);
cmSystemTools::ConvertToUnixSlashes(path);
- state->SetHomeDirectoryViaCommandLine(path, HomeDirArgStyle::Dash_S);
+ state->SetHomeDirectoryViaCommandLine(path);
return true;
};
@@ -1555,7 +1555,7 @@ bool cmake::SetDirectoriesFromFile(const std::string& arg)
// When invoked with a path that points to an existing CMakeCache
// This function is called multiple times with the same path
if (is_source_dir) {
- this->SetHomeDirectoryViaCommandLine(listPath, HomeDirArgStyle::Plain);
+ this->SetHomeDirectoryViaCommandLine(listPath);
if (no_build_tree) {
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
this->SetHomeOutputDirectory(cwd);
@@ -1780,28 +1780,19 @@ void cmake::PrintPresetList(const cmCMakePresetsGraph& graph) const
}
#endif
-void cmake::SetHomeDirectoryViaCommandLine(std::string const& path,
- HomeDirArgStyle argStyle)
+void cmake::SetHomeDirectoryViaCommandLine(std::string const& path)
{
- bool fromDashS = argStyle == HomeDirArgStyle::Dash_S;
- static bool homeDirectorySetExplicitly = false;
if (path.empty()) {
return;
}
auto prev_path = this->GetHomeDirectory();
if (prev_path != path && !prev_path.empty()) {
- const bool ignore_prev_path =
- (fromDashS || (!fromDashS && !homeDirectorySetExplicitly));
- const std::string& ignored_path = (ignore_prev_path) ? prev_path : path;
this->IssueMessage(MessageType::WARNING,
cmStrCat("Ignoring extra path from command line:\n \"",
- ignored_path, "\""));
+ prev_path, "\""));
}
- if (fromDashS || !homeDirectorySetExplicitly) {
- this->SetHomeDirectory(path);
- }
- homeDirectorySetExplicitly = fromDashS;
+ this->SetHomeDirectory(path);
}
void cmake::SetHomeDirectory(const std::string& dir)
diff --git a/Source/cmake.h b/Source/cmake.h
index 9c795c5..3c2a36c 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -183,12 +183,6 @@ public:
#endif
std::string ReportCapabilities() const;
- enum class HomeDirArgStyle
- {
- Plain,
- Dash_S,
- };
-
/**
* Set the home directory from `-S` or from a known location
* that contains a CMakeLists.txt. Will generate warnings
@@ -199,12 +193,11 @@ public:
* | `dirA dirA` | dirA | N/A |
* | `-S dirA -S dirA` | dirA | N/A |
* | `-S dirA -S dirB` | dirB | Ignoring dirA |
- * | `-S dirA dirB` | dirA | Ignoring dirB |
+ * | `-S dirA dirB` | dirB | Ignoring dirA |
* | `dirA -S dirB` | dirB | Ignoring dirA |
* | `dirA dirB` | dirB | Ignoring dirA |
*/
- void SetHomeDirectoryViaCommandLine(std::string const& path,
- HomeDirArgStyle argStyle);
+ void SetHomeDirectoryViaCommandLine(std::string const& path);
//@{
/**
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 081ee3f..f7554ff 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -180,7 +180,7 @@ message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'")
run_cmake_with_options(ExplicitDirs-S-S-same -S ${source_dir} -S ${source_dir} -B ${binary_dir})
run_cmake_with_options(ExplicitDirs-S-S-differs -S ${binary_dir}/other_dir -S ${source_dir} -B ${binary_dir})
run_cmake_with_options(ExplicitDirs-S-implicit-same -S ${source_dir} ${source_dir} -B ${binary_dir})
- run_cmake_with_options(ExplicitDirs-S-implicit-differs -S ${source_dir} ${binary_dir}/other_dir -B ${binary_dir})
+ run_cmake_with_options(ExplicitDirs-S-implicit-differs -S ${binary_dir}/other_dir ${source_dir} -B ${binary_dir})
run_cmake_with_options(ExplicitDirs-S-implicit-differs2 ${binary_dir}/other_dir -S ${source_dir} -B ${binary_dir})
run_cmake_with_options(ExplicitDirs-S-implicit-differs3 ${binary_dir}/other_dir ${source_dir} -B ${binary_dir})
run_cmake_with_options(ExplicitDirs-S-S-Sdiffers -S ${binary_dir}/other_dir1 -S ${binary_dir}/other_dir2 -S ${source_dir} -B ${binary_dir})