summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/ci/configure_common.cmake4
-rw-r--r--.gitlab/ci/configure_debian10_ninja.cmake4
-rw-r--r--.gitlab/ci/configure_fedora38_makefiles_clang.cmake4
-rw-r--r--.gitlab/ci/configure_macos_arm64_ninja_multi.cmake1
-rw-r--r--.gitlab/ci/configure_windows_vs2019_x64.cmake4
-rw-r--r--Help/command/if.rst6
-rw-r--r--Modules/FindCUDAToolkit.cmake25
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmAddCustomCommandCommand.cxx10
-rw-r--r--Source/cmAddCustomTargetCommand.cxx20
-rw-r--r--Source/cmCustomCommand.cxx10
-rw-r--r--Source/cmCustomCommand.h6
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx9
-rw-r--r--Source/cmPolicies.cxx160
-rw-r--r--Source/cmUVProcessChain.cxx4
-rw-r--r--Source/cmUVProcessChain.h2
-rw-r--r--Tests/CMakeLib/testUVProcessChain.cxx19
-rw-r--r--Tests/RunCMake/Make/Foo/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake32
-rw-r--r--Tests/RunCMake/Make/GNUMakeJobServerAware.cmake27
20 files changed, 217 insertions, 136 deletions
diff --git a/.gitlab/ci/configure_common.cmake b/.gitlab/ci/configure_common.cmake
index c207a74..f03c4b8 100644
--- a/.gitlab/ci/configure_common.cmake
+++ b/.gitlab/ci/configure_common.cmake
@@ -13,6 +13,10 @@ set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY "ON" CACHE BOOL "")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "")
set(CMake_TEST_INSTALL "OFF" CACHE BOOL "")
+set(CTEST_TEST_CTEST ON CACHE BOOL "")
+set(CMAKE_RUN_LONG_TESTS ON CACHE BOOL "")
+set(CMAKE_TESTS_CDASH_SERVER "NOTFOUND" CACHE STRING "")
+
if (NOT "$ENV{CMAKE_CI_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "$ENV{CMAKE_CI_BUILD_TYPE}" CACHE STRING "")
endif ()
diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake
index eca92bc..0576d11 100644
--- a/.gitlab/ci/configure_debian10_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_ninja.cmake
@@ -107,4 +107,8 @@ if (NOT "$ENV{SWIFTC}" STREQUAL "")
set(CMAKE_Swift_COMPILER "$ENV{SWIFTC}" CACHE FILEPATH "")
endif()
+if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
+ set(CMAKE_TESTS_CDASH_SERVER "https://open.cdash.org" CACHE STRING "")
+endif()
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/configure_fedora38_makefiles_clang.cmake b/.gitlab/ci/configure_fedora38_makefiles_clang.cmake
index ff30ad9..3ac23be 100644
--- a/.gitlab/ci/configure_fedora38_makefiles_clang.cmake
+++ b/.gitlab/ci/configure_fedora38_makefiles_clang.cmake
@@ -1 +1,5 @@
+if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
+ set(CMAKE_TESTS_CDASH_SERVER "https://open.cdash.org" CACHE STRING "")
+endif()
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora38_common_clang.cmake")
diff --git a/.gitlab/ci/configure_macos_arm64_ninja_multi.cmake b/.gitlab/ci/configure_macos_arm64_ninja_multi.cmake
index d81bd30..5b19c60 100644
--- a/.gitlab/ci/configure_macos_arm64_ninja_multi.cmake
+++ b/.gitlab/ci/configure_macos_arm64_ninja_multi.cmake
@@ -1,5 +1,6 @@
if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
set(CMake_TEST_ISPC "ON" CACHE STRING "")
+ set(CMAKE_TESTS_CDASH_SERVER "https://open.cdash.org" CACHE STRING "")
endif()
# FIXME: sccache sometimes fails with "Compiler killed by signal 9".
diff --git a/.gitlab/ci/configure_windows_vs2019_x64.cmake b/.gitlab/ci/configure_windows_vs2019_x64.cmake
index c7d41ea..b859525 100644
--- a/.gitlab/ci/configure_windows_vs2019_x64.cmake
+++ b/.gitlab/ci/configure_windows_vs2019_x64.cmake
@@ -1 +1,5 @@
+if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
+ set(CMAKE_TESTS_CDASH_SERVER "https://open.cdash.org" CACHE STRING "")
+endif()
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_vs_common.cmake")
diff --git a/Help/command/if.rst b/Help/command/if.rst
index be855e1..c47c71b 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -170,9 +170,9 @@ File Operations
.. signature:: if(EXISTS <path-to-file-or-directory>)
- True if the named file or directory exists. Behavior is well-defined
- only for explicit full paths (a leading ``~/`` is not expanded as
- a home directory and is considered a relative path).
+ True if the named file or directory exists and is readable. Behavior
+ is well-defined only for explicit full paths (a leading ``~/`` is not
+ expanded as a home directory and is considered a relative path).
Resolves symbolic links, i.e. if the named file or directory is a
symbolic link, returns true if the target of the symbolic link exists.
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index e9b7ae4..12aca8d 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -1012,17 +1012,26 @@ if(CUDAToolkit_FOUND)
)
# Don't try any stub directories until we have exhausted all other
# search locations.
- find_library(CUDA_${lib_name}_LIBRARY
- NAMES ${search_names}
- HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS}
- ENV CUDA_PATH
- PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs
- )
+ set(CUDA_IMPORT_PROPERTY IMPORTED_LOCATION)
+ set(CUDA_IMPORT_TYPE UNKNOWN)
+ if(NOT CUDA_${lib_name}_LIBRARY)
+ find_library(CUDA_${lib_name}_LIBRARY
+ NAMES ${search_names}
+ HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS}
+ ENV CUDA_PATH
+ PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs
+ )
+ if(CUDA_${lib_name}_LIBRARY AND NOT WIN32)
+ # Use `IMPORTED_IMPLIB` so that we don't add a `-rpath` entry for stub directories
+ set(CUDA_IMPORT_PROPERTY IMPORTED_IMPLIB)
+ set(CUDA_IMPORT_TYPE SHARED)
+ endif()
+ endif()
mark_as_advanced(CUDA_${lib_name}_LIBRARY)
if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY)
- add_library(CUDA::${lib_name} UNKNOWN IMPORTED)
+ add_library(CUDA::${lib_name} ${CUDA_IMPORT_TYPE} IMPORTED)
target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}")
if(DEFINED CUDAToolkit_MATH_INCLUDE_DIR)
string(FIND ${CUDA_${lib_name}_LIBRARY} "math_libs" math_libs)
@@ -1030,7 +1039,7 @@ if(CUDAToolkit_FOUND)
target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_MATH_INCLUDE_DIR}")
endif()
endif()
- set_property(TARGET CUDA::${lib_name} PROPERTY IMPORTED_LOCATION "${CUDA_${lib_name}_LIBRARY}")
+ set_property(TARGET CUDA::${lib_name} PROPERTY ${CUDA_IMPORT_PROPERTY} "${CUDA_${lib_name}_LIBRARY}")
foreach(dep ${arg_DEPS})
if(TARGET CUDA::${dep})
target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dep})
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 38046ab..d6546f2 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 27)
-set(CMake_VERSION_PATCH 20230726)
+set(CMake_VERSION_PATCH 20230727)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 044b5df..b1589ff 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -334,15 +334,6 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
return false;
}
- // If using a GNU Make generator and `JOB_SERVER_AWARE` is set then
- // prefix all commands with '+'.
- if (cmIsOn(job_server_aware) &&
- mf.GetGlobalGenerator()->IsGNUMakeJobServerAware()) {
- for (auto& commandLine : commandLines) {
- commandLine.insert(commandLine.begin(), "+");
- }
- }
-
// Choose which mode of the command to use.
auto cc = cm::make_unique<cmCustomCommand>();
cc->SetByproducts(byproducts);
@@ -353,6 +344,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
cc->SetUsesTerminal(uses_terminal);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
+ cc->SetJobserverAware(cmIsOn(job_server_aware));
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDependsExplicitOnly(depends_explicit_only);
if (source.empty() && output.empty()) {
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 6339062..711eaa5 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -55,7 +55,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
const char* comment = nullptr;
std::vector<std::string> sources;
std::string job_pool;
- std::string JOB_SERVER_AWARE;
+ std::string job_server_aware;
// Keep track of parser state.
enum tdoing
@@ -67,7 +67,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
doing_comment,
doing_source,
doing_job_pool,
- doing_JOB_SERVER_AWARE,
+ doing_job_server_aware,
doing_nothing
};
tdoing doing = doing_command;
@@ -106,7 +106,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
} else if (copy == "JOB_POOL") {
doing = doing_job_pool;
} else if (copy == "JOB_SERVER_AWARE") {
- doing = doing_JOB_SERVER_AWARE;
+ doing = doing_job_server_aware;
} else if (copy == "COMMAND") {
doing = doing_command;
@@ -153,8 +153,8 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
case doing_job_pool:
job_pool = copy;
break;
- case doing_JOB_SERVER_AWARE:
- JOB_SERVER_AWARE = copy;
+ case doing_job_server_aware:
+ job_server_aware = copy;
break;
default:
status.SetError("Wrong syntax. Unknown type of argument.");
@@ -220,15 +220,6 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
return false;
}
- // If using a GNU Make generator and `JOB_SERVER_AWARE` is set then
- // prefix all commands with '+'.
- if (cmIsOn(JOB_SERVER_AWARE) &&
- mf.GetGlobalGenerator()->IsGNUMakeJobServerAware()) {
- for (auto& commandLine : commandLines) {
- commandLine.insert(commandLine.begin(), "+");
- }
- }
-
// Add the utility target to the makefile.
auto cc = cm::make_unique<cmCustomCommand>();
cc->SetWorkingDirectory(working_directory.c_str());
@@ -240,6 +231,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetJobPool(job_pool);
+ cc->SetJobserverAware(cmIsOn(job_server_aware));
cmTarget* target =
mf.AddUtilityCommand(targetName, excludeFromAll, std::move(cc));
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index e12cf70..9958e4d 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -194,6 +194,16 @@ void cmCustomCommand::SetJobPool(const std::string& job_pool)
this->JobPool = job_pool;
}
+bool cmCustomCommand::GetJobserverAware() const
+{
+ return this->JobserverAware;
+}
+
+void cmCustomCommand::SetJobserverAware(bool b)
+{
+ this->JobserverAware = b;
+}
+
#define DEFINE_CC_POLICY_ACCESSOR(P) \
cmPolicies::PolicyStatus cmCustomCommand::Get##P##Status() const \
{ \
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 1e68dbf..167e601 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -115,6 +115,11 @@ public:
const std::string& GetJobPool() const;
void SetJobPool(const std::string& job_pool);
+ /** Set/Get whether this custom command should be given access to the
+ jobserver (if possible). */
+ bool GetJobserverAware() const;
+ void SetJobserverAware(bool b);
+
#define DECLARE_CC_POLICY_ACCESSOR(P) \
cmPolicies::PolicyStatus Get##P##Status() const;
CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DECLARE_CC_POLICY_ACCESSOR)
@@ -139,6 +144,7 @@ private:
std::string WorkingDirectory;
std::string Depfile;
std::string JobPool;
+ bool JobserverAware = false;
bool HaveComment = false;
bool EscapeAllowMakeVars = false;
bool EscapeOldStyle = true;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 3c6b303..e26a6ea 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1080,6 +1080,15 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
// Setup the proper working directory for the commands.
this->CreateCDCommand(commands1, dir, relative);
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+
+ // Prefix the commands with the jobserver prefix "+"
+ if (ccg.GetCC().GetJobserverAware() && gg->IsGNUMakeJobServerAware()) {
+ std::transform(commands1.begin(), commands1.end(), commands1.begin(),
+ [](std::string const& cmd) { return cmStrCat("+", cmd); });
+ }
+
// push back the custom commands
cm::append(commands, commands1);
}
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index d5e5725..d89c8c8 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -123,23 +123,23 @@ static void DiagnoseAncientPolicies(
{
std::ostringstream e;
e << "The project requests behavior compatible with CMake version \""
- << majorVer << "." << minorVer << "." << patchVer
+ << majorVer << '.' << minorVer << '.' << patchVer
<< "\", which requires the OLD behavior for some policies:\n";
for (cmPolicies::PolicyID i : ancient) {
- e << " " << idToString(i) << ": " << idToShortDescription(i) << "\n";
+ e << " " << idToString(i) << ": " << idToShortDescription(i) << '\n';
}
e << "However, this version of CMake no longer supports the OLD "
- << "behavior for these policies. "
- << "Please either update your CMakeLists.txt files to conform to "
- << "the new behavior or use an older version of CMake that still "
- << "supports the old behavior.";
+ "behavior for these policies. "
+ "Please either update your CMakeLists.txt files to conform to "
+ "the new behavior or use an older version of CMake that still "
+ "supports the old behavior.";
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultSetting)
{
- std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
+ std::string defaultVar = cmStrCat("CMAKE_POLICY_DEFAULT_", policy);
std::string const& defaultValue = mf->GetSafeDefinition(defaultVar);
if (defaultValue == "NEW") {
*defaultSetting = cmPolicies::NEW;
@@ -148,10 +148,10 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
} else if (defaultValue.empty()) {
*defaultSetting = cmPolicies::WARN;
} else {
- std::ostringstream e;
- e << defaultVar << " has value \"" << defaultValue
- << R"(" but must be "OLD", "NEW", or "" (empty).)";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(defaultVar, " has value \"", defaultValue,
+ R"(" but must be "OLD", "NEW", or "" (empty).)"));
return false;
}
@@ -170,10 +170,11 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
unsigned int minTweak = 0;
if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &minMajor, &minMinor,
&minPatch, &minTweak) < 2) {
- std::ostringstream e;
- e << "Invalid policy version value \"" << version_min << "\". "
- << "A numeric major.minor[.patch[.tweak]] must be given.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Invalid policy version value \"", version_min,
+ "\". "
+ "A numeric major.minor[.patch[.tweak]] must be given."));
return false;
}
@@ -199,13 +200,14 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
minMinor == cmVersion::GetMinorVersion() &&
minPatch == cmVersion::GetPatchVersion() &&
minTweak > cmVersion::GetTweakVersion())) {
- std::ostringstream e;
- e << "An attempt was made to set the policy version of CMake to \""
- << version_min << "\" which is greater than this version of CMake. "
- << "This is not allowed because the greater version may have new "
- << "policies not known to this CMake. "
- << "You may need a newer CMake version to build this project.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("An attempt was made to set the policy version of CMake to \"",
+ version_min,
+ "\" which is greater than this version of CMake. ",
+ "This is not allowed because the greater version may have new "
+ "policies not known to this CMake. "
+ "You may need a newer CMake version to build this project."));
return false;
}
@@ -221,10 +223,11 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
unsigned int maxTweak = 0;
if (sscanf(version_max.c_str(), "%u.%u.%u.%u", &maxMajor, &maxMinor,
&maxPatch, &maxTweak) < 2) {
- std::ostringstream e;
- e << "Invalid policy max version value \"" << version_max << "\". "
- << "A numeric major.minor[.patch[.tweak]] must be given.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Invalid policy max version value \"", version_max,
+ "\". "
+ "A numeric major.minor[.patch[.tweak]] must be given."));
return false;
}
@@ -234,11 +237,10 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
minPatch > maxPatch) ||
(minMajor == maxMajor && minMinor == maxMinor &&
minPatch == maxPatch && minTweak > maxTweak)) {
- std::ostringstream e;
- e << "Policy VERSION range \"" << version_min << "..." << version_max
- << "\""
- << " specifies a larger minimum than maximum.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Policy VERSION range \"", version_min, "...", version_max,
+ "\" specifies a larger minimum than maximum."));
return false;
}
@@ -328,61 +330,49 @@ bool cmPolicies::GetPolicyID(const char* id, cmPolicies::PolicyID& pid)
//! return a warning string for a given policy
std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
{
- std::ostringstream msg;
- msg << "Policy " << idToString(id)
- << " is not set: "
- ""
- << idToShortDescription(id)
- << " "
- "Run \"cmake --help-policy "
- << idToString(id)
- << "\" for "
- "policy details. "
- "Use the cmake_policy command to set the policy "
- "and suppress this warning.";
- return msg.str();
+ return cmStrCat("Policy ", idToString(id),
+ " is not set: ", idToShortDescription(id),
+ " "
+ "Run \"cmake --help-policy ",
+ idToString(id),
+ "\" for "
+ "policy details. "
+ "Use the cmake_policy command to set the policy "
+ "and suppress this warning.");
}
std::string cmPolicies::GetPolicyDeprecatedWarning(cmPolicies::PolicyID id)
{
- std::ostringstream msg;
- /* clang-format off */
- msg <<
- "The OLD behavior for policy " << idToString(id) << " "
+ return cmStrCat(
+ "The OLD behavior for policy ", idToString(id),
+ " "
"will be removed from a future version of CMake.\n"
"The cmake-policies(7) manual explains that the OLD behaviors of all "
"policies are deprecated and that a policy should be set to OLD only "
"under specific short-term circumstances. Projects should be ported "
- "to the NEW behavior and not rely on setting a policy to OLD."
- ;
- /* clang-format on */
- return msg.str();
+ "to the NEW behavior and not rely on setting a policy to OLD.");
}
//! return an error string for when a required policy is unspecified
std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
{
- std::ostringstream error;
- error << "Policy " << idToString(id)
- << " is not set to NEW: "
- ""
- << idToShortDescription(id)
- << " "
- "Run \"cmake --help-policy "
- << idToString(id)
- << "\" for "
- "policy details. "
- "CMake now requires this policy to be set to NEW by the project. "
- "The policy may be set explicitly using the code\n"
- " cmake_policy(SET "
- << idToString(id)
- << " NEW)\n"
- "or by upgrading all policies with the code\n"
- " cmake_policy(VERSION "
- << idToVersion(id)
- << ") # or later\n"
- "Run \"cmake --help-command cmake_policy\" for more information.";
- return error.str();
+ return cmStrCat(
+ "Policy ", idToString(id),
+ " is not set to NEW: ", idToShortDescription(id),
+ " "
+ "Run \"cmake --help-policy ",
+ idToString(id),
+ "\" for policy details. "
+ "CMake now requires this policy to be set to NEW by the project. "
+ "The policy may be set explicitly using the code\n"
+ " cmake_policy(SET ",
+ idToString(id),
+ " NEW)\n"
+ "or by upgrading all policies with the code\n"
+ " cmake_policy(VERSION ",
+ idToVersion(id),
+ ") # or later\n"
+ "Run \"cmake --help-command cmake_policy\" for more information.");
}
//! Get the default status for a policy
@@ -395,18 +385,18 @@ cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus(
std::string cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
{
std::string pid = idToString(id);
- std::ostringstream e;
- e << "Policy " << pid << " may not be set to OLD behavior because this "
- << "version of CMake no longer supports it. "
- << "The policy was introduced in "
- << "CMake version " << idToVersion(id)
- << ", and use of NEW behavior is now required."
- << "\n"
- << "Please either update your CMakeLists.txt files to conform to "
- << "the new behavior or use an older version of CMake that still "
- << "supports the old behavior. "
- << "Run cmake --help-policy " << pid << " for more information.";
- return e.str();
+ return cmStrCat(
+ "Policy ", pid,
+ " may not be set to OLD behavior because this "
+ "version of CMake no longer supports it. "
+ "The policy was introduced in CMake version ",
+ idToVersion(id),
+ ", and use of NEW behavior is now required."
+ "\n"
+ "Please either update your CMakeLists.txt files to conform to "
+ "the new behavior or use an older version of CMake that still "
+ "supports the old behavior. Run cmake --help-policy ",
+ pid, " for more information.");
}
cmPolicies::PolicyStatus cmPolicies::PolicyMap::Get(
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx
index 3de7ae5..119851c 100644
--- a/Source/cmUVProcessChain.cxx
+++ b/Source/cmUVProcessChain.cxx
@@ -393,12 +393,12 @@ bool cmUVProcessChain::Valid() const
return this->Data->Valid;
}
-bool cmUVProcessChain::Wait(int64_t milliseconds)
+bool cmUVProcessChain::Wait(uint64_t milliseconds)
{
bool timeout = false;
cm::uv_timer_ptr timer;
- if (milliseconds >= 0) {
+ if (milliseconds > 0) {
timer.init(*this->Data->Loop, &timeout);
timer.start(
[](uv_timer_t* handle) {
diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h
index d7a4a0e..5ba1bf9 100644
--- a/Source/cmUVProcessChain.h
+++ b/Source/cmUVProcessChain.h
@@ -102,7 +102,7 @@ public:
int ErrorStream();
bool Valid() const;
- bool Wait(int64_t milliseconds = -1);
+ bool Wait(uint64_t milliseconds = 0);
std::vector<const Status*> GetStatus() const;
const Status& GetStatus(std::size_t index) const;
bool Finished() const;
diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx
index 7630aa0..22373ef 100644
--- a/Tests/CMakeLib/testUVProcessChain.cxx
+++ b/Tests/CMakeLib/testUVProcessChain.cxx
@@ -652,6 +652,20 @@ bool testUVProcessChainInputFile(const char* helperCommand)
return true;
}
+bool testUVProcessChainWait0(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ builder.AddCommand({ helperCommand, "echo" });
+
+ auto chain = builder.Start();
+ if (!chain.Wait(0)) {
+ std::cout << "Wait(0) returned false, should be true" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
int testUVProcessChain(int argc, char** const argv)
{
if (argc < 2) {
@@ -699,5 +713,10 @@ int testUVProcessChain(int argc, char** const argv)
return -1;
}
+ if (!testUVProcessChainWait0(argv[1])) {
+ std::cout << "While executing testUVProcessChainWait0().\n";
+ return -1;
+ }
+
return 0;
}
diff --git a/Tests/RunCMake/Make/Foo/CMakeLists.txt b/Tests/RunCMake/Make/Foo/CMakeLists.txt
new file mode 100644
index 0000000..baa6634
--- /dev/null
+++ b/Tests/RunCMake/Make/Foo/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.26)
+project(Foo NONE)
+
+add_custom_target(drive ALL COMMAND ${CMAKE_COMMAND} -E true)
diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake
index 7c5c296..da18f00 100644
--- a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake
+++ b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake
@@ -1,12 +1,26 @@
-# This test verifies that the commands in the generated Makefiles contain the
-# `+` prefix
-function(check_for_plus_prefix target)
- set(file "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build/${target}")
- file(READ "${file}" build_file)
- if(NOT "${build_file}" MATCHES [[\+]])
- message(FATAL_ERROR "The file ${file} does not contain the expected prefix in the custom command.")
+set(BUILD_DIR "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build")
+
+function(check target line)
+ # Read the file and split it into a list of lines
+ file(READ ${BUILD_DIR}/${target} contents)
+ STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
+ STRING(REGEX REPLACE "\n" ";" contents "${contents}")
+
+ set(found FALSE)
+ foreach(entry ${contents})
+ if("${entry}" MATCHES "${line}")
+ set(found TRUE)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT found)
+ message(FATAL_ERROR "Could not find '${line}' in ${BUILD_DIR}/${target}\n${contents}")
endif()
endfunction()
-check_for_plus_prefix("CMakeFiles/dummy.dir/build.make")
-check_for_plus_prefix("CMakeFiles/dummy2.dir/build.make")
+check("CMakeFiles/dummy.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]])
+check("CMakeFiles/dummy2.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]])
+
+check("CMakeFiles/dummy3.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]])
+check("CMakeFiles/dummy4.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]])
diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake
index 951c2d7..d92e842 100644
--- a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake
+++ b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake
@@ -1,12 +1,31 @@
+# Test JOB_SERVER_AWARE with custom commands
add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/custom-command"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing"
JOB_SERVER_AWARE ON
- COMMAND $(CMAKE_COMMAND) -E touch "${CMAKE_CURRENT_BINARY_DIR}/custom-command"
+ COMMAND $(CMAKE_COMMAND) -E true
)
-add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/custom-command")
+add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing")
+# Test JOB_SERVER_AWARE with custom targets
add_custom_target(
dummy2 ALL
JOB_SERVER_AWARE ON
- COMMAND ${CMAKE_COMMAND} -E true
+ COMMAND $(CMAKE_COMMAND) -E true
+)
+
+# Test JOB_SERVER_AWARE with custom commands with WORKING_DIRECTORY
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing2"
+ JOB_SERVER_AWARE ON
+ COMMAND $(CMAKE_COMMAND) -E true
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo"
+)
+add_custom_target(dummy3 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing2")
+
+# Test JOB_SERVER_AWARE with custom targets with WORKING_DIRECTORY
+add_custom_target(
+ dummy4 ALL
+ JOB_SERVER_AWARE ON
+ COMMAND $(CMAKE_COMMAND) -E true
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo"
)