summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/ci/ctest_exclusions.cmake9
-rw-r--r--.gitlab/ci/ctest_test_external.cmake5
-rw-r--r--Help/dev/maint.rst18
-rw-r--r--Help/release/dev/FindSWIG-version-range.rst4
-rw-r--r--Modules/FindSWIG.cmake41
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCMakeLanguageCommand.cxx12
-rw-r--r--Source/cmCPluginAPI.cxx9
-rw-r--r--Source/cmForEachCommand.cxx2
-rw-r--r--Source/cmFunctionBlocker.cxx4
-rw-r--r--Source/cmFunctionCommand.cxx2
-rw-r--r--Source/cmIfCommand.cxx23
-rw-r--r--Source/cmListFileCache.cxx23
-rw-r--r--Source/cmListFileCache.h57
-rw-r--r--Source/cmMacroCommand.cxx15
-rw-r--r--Source/cmMakefile.cxx42
-rw-r--r--Source/cmMakefileProfilingData.cxx6
-rw-r--r--Source/cmMakefileProfilingData.h2
-rw-r--r--Source/cmVariableWatchCommand.cxx9
-rw-r--r--Source/cmWhileCommand.cxx2
-rw-r--r--Tests/RunCMake/FindSWIG/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/FindSWIG/version-range.cmake30
22 files changed, 225 insertions, 93 deletions
diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake
index b885a6a..a68a693 100644
--- a/.gitlab/ci/ctest_exclusions.cmake
+++ b/.gitlab/ci/ctest_exclusions.cmake
@@ -13,6 +13,15 @@ if (CTEST_CMAKE_GENERATOR MATCHES "Visual Studio")
"^ExternalProjectUpdateSetup$")
endif ()
+if (CMAKE_HOST_WIN32)
+ list(APPEND test_exclusions
+ # This test often fails with an undiagnosed subtle race due to the test
+ # re-using the same objects for many files. Some copy operations fail
+ # to open their input with ERROR_SHARING_VIOLATION.
+ "^Module.ExternalData$"
+ )
+endif()
+
string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
if (test_exclusions)
set(test_exclusions "(${test_exclusions})")
diff --git a/.gitlab/ci/ctest_test_external.cmake b/.gitlab/ci/ctest_test_external.cmake
index d92b936..4ea060d 100644
--- a/.gitlab/ci/ctest_test_external.cmake
+++ b/.gitlab/ci/ctest_test_external.cmake
@@ -33,6 +33,11 @@ endif ()
include(ProcessorCount)
ProcessorCount(nproc)
+if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
+ if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
+ set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
+ endif ()
+endif ()
if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(CTEST_BUILD_FLAGS "-j${nproc}")
diff --git a/Help/dev/maint.rst b/Help/dev/maint.rst
index 4c2c89f..75d685c 100644
--- a/Help/dev/maint.rst
+++ b/Help/dev/maint.rst
@@ -245,6 +245,20 @@ Commit with a message such as::
Release versions do not have the development topic section of
the CMake Release Notes index page.
+Update ``.gitlab-ci.yml`` to drop the ``upload:`` jobs from the
+packaging pipeline by renaming them to start in ``.``:
+
+.. code-block:: shell
+
+ sed -i 's/^upload:/.upload:/' .gitlab-ci.yml
+
+Commit with a message such as::
+
+ gitlab-ci: Drop package pipeline upload jobs for release branch
+
+ The package pipeline for release versions should not upload packages
+ automatically to our archive of nightly development versions.
+
Update ``Source/CMakeVersion.cmake`` to set the version to
``$major.$minor.0-rc0``:
@@ -276,13 +290,15 @@ Merge the ``release-$ver`` branch to ``master``:
git merge --no-ff release-$ver
Begin post-release development by restoring the development branch release
-note infrastructure and the version date from ``origin/master``:
+note infrastructure, the nightly package pipeline upload jobs, and
+the version date from ``origin/master``:
.. code-block:: shell
git checkout origin/master -- \
Source/CMakeVersion.cmake Help/release/dev/0-sample-topic.rst
sed -i $'/^Releases/ i\\\n.. include:: dev.txt\\\n' Help/release/index.rst
+ sed -i 's/^\.upload:/upload:/' .gitlab-ci.yml
Update ``Source/CMakeVersion.cmake`` to set the version to
``$major.$minor.$date``:
diff --git a/Help/release/dev/FindSWIG-version-range.rst b/Help/release/dev/FindSWIG-version-range.rst
new file mode 100644
index 0000000..37567d3
--- /dev/null
+++ b/Help/release/dev/FindSWIG-version-range.rst
@@ -0,0 +1,4 @@
+FindSWIG-version-range
+----------------------
+
+* :module:`FindSWIG` module gains the capability to manage a version range.
diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake
index 2fded49..f732289 100644
--- a/Modules/FindSWIG.cmake
+++ b/Modules/FindSWIG.cmake
@@ -7,11 +7,16 @@ FindSWIG
Find the Simplified Wrapper and Interface Generator (SWIG_) executable.
-
This module finds an installed SWIG and determines its version. If a
-``COMPONENTS`` or ``OPTIONAL_COMPONENTS`` argument is given to ``find_package``,
-it will also determine supported target languages. The module sents the
-following variables:
+``COMPONENTS`` or ``OPTIONAL_COMPONENTS`` argument is given to the
+:command:`find_package` command, it will also determine supported target
+languages.
+
+When a version is requested, it can be specified as a simple value or as a
+range. For a detailed description of version range usage and capabilities,
+refer to the :command:`find_package` command.
+
+The module defines the following variables:
``SWIG_FOUND``
Whether SWIG and any required components were found on the system.
@@ -50,7 +55,30 @@ optional Fortran support:
#]=======================================================================]
-find_program(SWIG_EXECUTABLE NAMES swig4.0 swig3.0 swig2.0 swig)
+# compute list of possible names
+if (SWIG_FIND_VERSION_RANGE)
+ set (_SWIG_NAMES)
+ foreach (_SWIG_MAJOR IN ITEMS 4 3 2)
+ if (_SWIG_MAJOR VERSION_GREATER_EQUAL SWIG_FIND_VERSION_MIN_MAJOR
+ AND ((SWIG_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND _SWIG_MAJOR VERSION_LESS_EQUAL SWIG_FIND_VERSION_MAX)
+ OR (SWIG_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND _SWIG_MAJOR VERSION_LESS SWIG_FIND_VERSION_MAX)))
+ list (APPEND _SWIG_NAMES swig${_SWIG_MAJOR}.0)
+ endif()
+ endforeach()
+elseif(SWIG_FIND_VERSION)
+ if (SWIG_FIND_VERSION_EXACT)
+ set(_SWIG_NAMES swig${SWIG_FIND_VERSION_MAJOR}.0)
+ else()
+ foreach (_SWIG_MAJOR IN ITEMS 4 3 2)
+ if (_SWIG_MAJOR VERSION_GREATER_EQUAL SWIG_FIND_VERSION_MAJOR)
+ list (APPEND _SWIG_NAMES swig${_SWIG_MAJOR}.0)
+ endif()
+ endif()
+else()
+ set (_SWIG_NAMES swig4.0 swig3.0 swig2.0)
+endif()
+
+find_program(SWIG_EXECUTABLE NAMES ${_SWIG_NAMES} swig)
if(SWIG_EXECUTABLE)
execute_process(COMMAND ${SWIG_EXECUTABLE} -swiglib
@@ -105,6 +133,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(
SWIG HANDLE_COMPONENTS
REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
- VERSION_VAR SWIG_VERSION)
+ VERSION_VAR SWIG_VERSION
+ HANDLE_VERSION_RANGE)
mark_as_advanced(SWIG_DIR SWIG_VERSION SWIG_EXECUTABLE)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index ce9646d..524dea1 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 18)
-set(CMake_VERSION_PATCH 20201001)
+set(CMake_VERSION_PATCH 20201002)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx
index 9277c20..789c78d 100644
--- a/Source/cmCMakeLanguageCommand.cxx
+++ b/Source/cmCMakeLanguageCommand.cxx
@@ -77,18 +77,14 @@ bool cmCMakeLanguageCommandCALL(std::vector<cmListFileArgument> const& args,
cmMakefile& makefile = status.GetMakefile();
cmListFileContext context = makefile.GetBacktrace().Top();
- cmListFileFunction func;
- func.Name = callCommand;
- func.Line = context.Line;
+ std::vector<cmListFileArgument> funcArgs;
+ funcArgs.reserve(args.size() - startArg);
// The rest of the arguments are passed to the function call above
for (size_t i = startArg; i < args.size(); ++i) {
- cmListFileArgument lfarg;
- lfarg.Delim = args[i].Delim;
- lfarg.Line = context.Line;
- lfarg.Value = args[i].Value;
- func.Arguments.emplace_back(lfarg);
+ funcArgs.emplace_back(args[i].Value, args[i].Delim, context.Line);
}
+ cmListFileFunction func{ callCommand, context.Line, std::move(funcArgs) };
if (defer) {
if (defer->Id.empty()) {
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index ee2960b..8ebf6d2 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -419,12 +419,15 @@ int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
const char** args)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- cmListFileFunction lff;
- lff.Name = name;
+
+ std::vector<cmListFileArgument> lffArgs;
+ lffArgs.reserve(numArgs);
for (int i = 0; i < numArgs; ++i) {
// Assume all arguments are quoted.
- lff.Arguments.emplace_back(args[i], cmListFileArgument::Quoted, 0);
+ lffArgs.emplace_back(args[i], cmListFileArgument::Quoted, 0);
}
+
+ cmListFileFunction lff{ name, 0, std::move(lffArgs) };
cmExecutionStatus status(*mf);
return mf->ExecuteCommand(lff, status);
}
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 42df923..bcacb15 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -90,7 +90,7 @@ bool cmForEachFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile& mf) const
{
std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments);
+ mf.ExpandArguments(lff.Arguments(), expandedArguments);
return expandedArguments.empty() ||
expandedArguments.front() == this->Args.front();
}
diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx
index 643cd82..d4666d7 100644
--- a/Source/cmFunctionBlocker.cxx
+++ b/Source/cmFunctionBlocker.cxx
@@ -15,9 +15,9 @@
bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus& status)
{
- if (lff.Name.Lower == this->StartCommandName()) {
+ if (lff.LowerCaseName() == this->StartCommandName()) {
this->ScopeDepth++;
- } else if (lff.Name.Lower == this->EndCommandName()) {
+ } else if (lff.LowerCaseName() == this->EndCommandName()) {
this->ScopeDepth--;
if (this->ScopeDepth == 0U) {
cmMakefile& mf = status.GetMakefile();
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 46bd057..71c82d6 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -147,7 +147,7 @@ bool cmFunctionFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile& mf) const
{
std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments);
+ mf.ExpandArguments(lff.Arguments(), expandedArguments);
return expandedArguments.empty() ||
expandedArguments.front() == this->Args.front();
}
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index fc257b1..55f6453 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -54,7 +54,7 @@ public:
bool cmIfFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile&) const
{
- return lff.Arguments.empty() || lff.Arguments == this->Args;
+ return lff.Arguments().empty() || lff.Arguments() == this->Args;
}
bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
@@ -65,19 +65,19 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
int scopeDepth = 0;
for (cmListFileFunction const& func : functions) {
// keep track of scope depth
- if (func.Name.Lower == "if") {
+ if (func.LowerCaseName() == "if") {
scopeDepth++;
}
- if (func.Name.Lower == "endif") {
+ if (func.LowerCaseName() == "endif") {
scopeDepth--;
}
// watch for our state change
- if (scopeDepth == 0 && func.Name.Lower == "else") {
+ if (scopeDepth == 0 && func.LowerCaseName() == "else") {
if (this->ElseSeen) {
- cmListFileBacktrace elseBT = mf.GetBacktrace().Push(
- cmListFileContext{ func.Name.Original,
- this->GetStartingContext().FilePath, func.Line });
+ cmListFileBacktrace elseBT = mf.GetBacktrace().Push(cmListFileContext{
+ func.OriginalName(), this->GetStartingContext().FilePath,
+ func.Line() });
mf.GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"A duplicate ELSE command was found inside an IF block.", elseBT);
@@ -94,9 +94,10 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) {
mf.PrintCommandTrace(func);
}
- } else if (scopeDepth == 0 && func.Name.Lower == "elseif") {
- cmListFileBacktrace elseifBT = mf.GetBacktrace().Push(cmListFileContext{
- func.Name.Original, this->GetStartingContext().FilePath, func.Line });
+ } else if (scopeDepth == 0 && func.LowerCaseName() == "elseif") {
+ cmListFileBacktrace elseifBT = mf.GetBacktrace().Push(
+ cmListFileContext{ func.OriginalName(),
+ this->GetStartingContext().FilePath, func.Line() });
if (this->ElseSeen) {
mf.GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
@@ -116,7 +117,7 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
std::string errorString;
std::vector<cmExpandedCommandArgument> expandedArguments;
- mf.ExpandArguments(func.Arguments, expandedArguments);
+ mf.ExpandArguments(func.Arguments(), expandedArguments);
MessageType messType;
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index d678b56..70ef5af 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -15,14 +15,6 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmCommandContext::cmCommandName& cmCommandContext::cmCommandName::operator=(
- std::string const& name)
-{
- this->Original = name;
- this->Lower = cmSystemTools::LowerCase(name);
- return *this;
-}
-
struct cmListFileParser
{
cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
@@ -43,7 +35,9 @@ struct cmListFileParser
cmMessenger* Messenger;
const char* FileName;
cmListFileLexer* Lexer;
- cmListFileFunction Function;
+ std::string FunctionName;
+ long FunctionLine;
+ std::vector<cmListFileArgument> FunctionArguments;
enum
{
SeparationOkay,
@@ -141,7 +135,9 @@ bool cmListFileParser::Parse()
if (haveNewline) {
haveNewline = false;
if (this->ParseFunction(token->text, token->line)) {
- this->ListFile->Functions.push_back(this->Function);
+ this->ListFile->Functions.emplace_back(
+ std::move(this->FunctionName), this->FunctionLine,
+ std::move(this->FunctionArguments));
} else {
return false;
}
@@ -200,9 +196,8 @@ bool cmListFile::ParseString(const char* str, const char* virtual_filename,
bool cmListFileParser::ParseFunction(const char* name, long line)
{
// Ininitialize a new function call.
- this->Function = cmListFileFunction();
- this->Function.Name = name;
- this->Function.Line = line;
+ this->FunctionName = name;
+ this->FunctionLine = line;
// Command name has already been parsed. Read the left paren.
cmListFileLexer_Token* token;
@@ -297,7 +292,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
cmListFileArgument::Delimiter delim)
{
- this->Function.Arguments.emplace_back(token->text, delim, token->line);
+ this->FunctionArguments.emplace_back(token->text, delim, token->line);
if (this->Separation == SeparationOkay) {
return true;
}
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 5617536..727fc60 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -14,6 +14,7 @@
#include <cm/optional>
#include "cmStateSnapshot.h"
+#include "cmSystemTools.h"
/** \class cmListFileCache
* \brief A class to cache list file contents.
@@ -28,16 +29,19 @@ struct cmCommandContext
{
struct cmCommandName
{
- std::string Lower;
std::string Original;
+ std::string Lower;
cmCommandName() = default;
- cmCommandName(std::string const& name) { *this = name; }
- cmCommandName& operator=(std::string const& name);
+ cmCommandName(std::string name)
+ : Original(std::move(name))
+ , Lower(cmSystemTools::LowerCase(this->Original))
+ {
+ }
} Name;
long Line = 0;
cmCommandContext() = default;
- cmCommandContext(const char* name, int line)
- : Name(name)
+ cmCommandContext(std::string name, long line)
+ : Name(std::move(name))
, Line(line)
{
}
@@ -103,9 +107,48 @@ bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
-struct cmListFileFunction : public cmCommandContext
+class cmListFileFunction
{
- std::vector<cmListFileArgument> Arguments;
+public:
+ cmListFileFunction(std::string name, long line,
+ std::vector<cmListFileArgument> args)
+ : Impl{ std::make_shared<Implementation>(std::move(name), line,
+ std::move(args)) }
+ {
+ }
+
+ std::string const& OriginalName() const noexcept
+ {
+ return this->Impl->Name.Original;
+ }
+
+ std::string const& LowerCaseName() const noexcept
+ {
+ return this->Impl->Name.Lower;
+ }
+
+ long Line() const noexcept { return this->Impl->Line; }
+
+ std::vector<cmListFileArgument> const& Arguments() const noexcept
+ {
+ return this->Impl->Arguments;
+ }
+
+ operator cmCommandContext const&() const noexcept { return *this->Impl; }
+
+private:
+ struct Implementation : public cmCommandContext
+ {
+ Implementation(std::string name, long line,
+ std::vector<cmListFileArgument> args)
+ : cmCommandContext{ std::move(name), line }
+ , Arguments{ std::move(args) }
+ {
+ }
+ std::vector<cmListFileArgument> Arguments;
+ };
+
+ std::shared_ptr<Implementation const> Impl;
};
// Represent a backtrace (call stack). Provide value semantics
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 91a600e..98f88c1 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -81,17 +81,14 @@ bool cmMacroHelperCommand::operator()(
argVs.emplace_back(argvName);
}
// Invoke all the functions that were collected in the block.
- cmListFileFunction newLFF;
// for each function
for (cmListFileFunction const& func : this->Functions) {
// Replace the formal arguments and then invoke the command.
- newLFF.Arguments.clear();
- newLFF.Arguments.reserve(func.Arguments.size());
- newLFF.Name = func.Name;
- newLFF.Line = func.Line;
+ std::vector<cmListFileArgument> newLFFArgs;
+ newLFFArgs.reserve(func.Arguments().size());
// for each argument of the current function
- for (cmListFileArgument const& k : func.Arguments) {
+ for (cmListFileArgument const& k : func.Arguments()) {
cmListFileArgument arg;
arg.Value = k.Value;
if (k.Delim != cmListFileArgument::Bracket) {
@@ -116,8 +113,10 @@ bool cmMacroHelperCommand::operator()(
}
arg.Delim = k.Delim;
arg.Line = k.Line;
- newLFF.Arguments.push_back(std::move(arg));
+ newLFFArgs.push_back(std::move(arg));
}
+ cmListFileFunction newLFF{ func.OriginalName(), func.Line(),
+ std::move(newLFFArgs) };
cmExecutionStatus status(makefile);
if (!makefile.ExecuteCommand(newLFF, status) || status.GetNestedError()) {
// The error message should have already included the call stack
@@ -157,7 +156,7 @@ bool cmMacroFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile& mf) const
{
std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments);
+ mf.ExpandArguments(lff.Arguments(), expandedArguments);
return expandedArguments.empty() || expandedArguments[0] == this->Args[0];
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ac3a193..14ec689 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -306,8 +306,8 @@ void cmMakefile::PrintCommandTrace(
std::string temp;
bool expand = this->GetCMakeInstance()->GetTraceExpand();
- args.reserve(lff.Arguments.size());
- for (cmListFileArgument const& arg : lff.Arguments) {
+ args.reserve(lff.Arguments().size());
+ for (cmListFileArgument const& arg : lff.Arguments()) {
if (expand) {
temp = arg.Value;
this->ExpandVariablesInString(temp);
@@ -324,11 +324,11 @@ void cmMakefile::PrintCommandTrace(
Json::StreamWriterBuilder builder;
builder["indentation"] = "";
val["file"] = full_path;
- val["line"] = static_cast<Json::Value::Int64>(lff.Line);
+ val["line"] = static_cast<Json::Value::Int64>(lff.Line());
if (deferId) {
val["defer"] = *deferId;
}
- val["cmd"] = lff.Name.Original;
+ val["cmd"] = lff.OriginalName();
val["args"] = Json::Value(Json::arrayValue);
for (std::string const& arg : args) {
val["args"].append(arg);
@@ -341,11 +341,11 @@ void cmMakefile::PrintCommandTrace(
break;
}
case cmake::TraceFormat::TRACE_HUMAN:
- msg << full_path << "(" << lff.Line << "):";
+ msg << full_path << "(" << lff.Line() << "):";
if (deferId) {
msg << "DEFERRED:" << *deferId << ":";
}
- msg << " " << lff.Name.Original << "(";
+ msg << " " << lff.OriginalName() << "(";
for (std::string const& arg : args) {
msg << arg << " ";
@@ -451,7 +451,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
// Lookup the command prototype.
if (cmState::Command command =
- this->GetState()->GetCommandByExactName(lff.Name.Lower)) {
+ this->GetState()->GetCommandByExactName(lff.LowerCaseName())) {
// Decide whether to invoke the command.
if (!cmSystemTools::GetFatalErrorOccured()) {
// if trace is enabled, print out invoke information
@@ -459,13 +459,13 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
this->PrintCommandTrace(lff, this->Backtrace.Top().DeferId);
}
// Try invoking the command.
- bool invokeSucceeded = command(lff.Arguments, status);
+ bool invokeSucceeded = command(lff.Arguments(), status);
bool hadNestedError = status.GetNestedError();
if (!invokeSucceeded || hadNestedError) {
if (!hadNestedError) {
// The command invocation requested that we report an error.
std::string const error =
- std::string(lff.Name.Original) + " " + status.GetError();
+ std::string(lff.OriginalName()) + " " + status.GetError();
this->IssueMessage(MessageType::FATAL_ERROR, error);
}
result = false;
@@ -477,7 +477,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
} else {
if (!cmSystemTools::GetFatalErrorOccured()) {
std::string error =
- cmStrCat("Unknown CMake command \"", lff.Name.Original, "\".");
+ cmStrCat("Unknown CMake command \"", lff.OriginalName(), "\".");
this->IssueMessage(MessageType::FATAL_ERROR, error);
result = false;
cmSystemTools::SetFatalErrorOccured();
@@ -1690,7 +1690,7 @@ void cmMakefile::Configure()
bool hasVersion = false;
// search for the right policy command
for (cmListFileFunction const& func : listFile.Functions) {
- if (func.Name.Lower == "cmake_minimum_required") {
+ if (func.LowerCaseName() == "cmake_minimum_required") {
hasVersion = true;
break;
}
@@ -1717,7 +1717,7 @@ void cmMakefile::Configure()
allowedCommands.insert("message");
isProblem = false;
for (cmListFileFunction const& func : listFile.Functions) {
- if (!cm::contains(allowedCommands, func.Name.Lower)) {
+ if (!cm::contains(allowedCommands, func.LowerCaseName())) {
isProblem = true;
break;
}
@@ -1737,7 +1737,7 @@ void cmMakefile::Configure()
bool hasProject = false;
// search for a project command
for (cmListFileFunction const& func : listFile.Functions) {
- if (func.Name.Lower == "project") {
+ if (func.LowerCaseName() == "project") {
hasProject = true;
break;
}
@@ -1754,12 +1754,12 @@ void cmMakefile::Configure()
"CMake is pretending there is a \"project(Project)\" command on "
"the first line.",
this->Backtrace);
- cmListFileFunction project;
- project.Name.Lower = "project";
- project.Arguments.emplace_back("Project", cmListFileArgument::Unquoted,
- 0);
- project.Arguments.emplace_back("__CMAKE_INJECTED_PROJECT_COMMAND__",
- cmListFileArgument::Unquoted, 0);
+ cmListFileFunction project{ "project",
+ 0,
+ { { "Project", cmListFileArgument::Unquoted,
+ 0 },
+ { "__CMAKE_INJECTED_PROJECT_COMMAND__",
+ cmListFileArgument::Unquoted, 0 } } };
listFile.Functions.insert(listFile.Functions.begin(), project);
}
}
@@ -3105,8 +3105,8 @@ cm::optional<std::string> cmMakefile::DeferGetCall(std::string const& id) const
std::string tmp;
for (DeferCommand const& dc : this->Defer->Commands) {
if (dc.Id == id) {
- tmp = dc.Command.Name.Original;
- for (cmListFileArgument const& arg : dc.Command.Arguments) {
+ tmp = dc.Command.OriginalName();
+ for (cmListFileArgument const& arg : dc.Command.Arguments()) {
tmp = cmStrCat(tmp, ';', arg.Value);
}
break;
diff --git a/Source/cmMakefileProfilingData.cxx b/Source/cmMakefileProfilingData.cxx
index 29fd440..86188db 100644
--- a/Source/cmMakefileProfilingData.cxx
+++ b/Source/cmMakefileProfilingData.cxx
@@ -58,7 +58,7 @@ void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff,
cmsys::SystemInformation info;
Json::Value v;
v["ph"] = "B";
- v["name"] = lff.Name.Lower;
+ v["name"] = lff.LowerCaseName();
v["cat"] = "cmake";
v["ts"] = Json::Value::UInt64(
std::chrono::duration_cast<std::chrono::microseconds>(
@@ -67,9 +67,9 @@ void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff,
v["pid"] = static_cast<int>(info.GetProcessId());
v["tid"] = 0;
Json::Value argsValue;
- if (!lff.Arguments.empty()) {
+ if (!lff.Arguments().empty()) {
std::string args;
- for (const auto& a : lff.Arguments) {
+ for (auto const& a : lff.Arguments()) {
args += (args.empty() ? "" : " ") + a.Value;
}
argsValue["functionArgs"] = args;
diff --git a/Source/cmMakefileProfilingData.h b/Source/cmMakefileProfilingData.h
index a3f128b..a86764a 100644
--- a/Source/cmMakefileProfilingData.h
+++ b/Source/cmMakefileProfilingData.h
@@ -11,7 +11,7 @@ class StreamWriter;
}
class cmListFileContext;
-struct cmListFileFunction;
+class cmListFileFunction;
class cmMakefileProfilingData
{
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 750b0b5..7c7fbca 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -45,20 +45,21 @@ void cmVariableWatchCommandVariableAccessed(const std::string& variable,
std::string stack = *mf->GetProperty("LISTFILE_STACK");
if (!data->Command.empty()) {
- cmListFileFunction newLFF;
cmProp const currentListFile =
mf->GetDefinition("CMAKE_CURRENT_LIST_FILE");
const auto fakeLineNo =
std::numeric_limits<decltype(cmListFileArgument::Line)>::max();
- newLFF.Arguments = {
+
+ std::vector<cmListFileArgument> newLFFArgs{
{ variable, cmListFileArgument::Quoted, fakeLineNo },
{ accessString, cmListFileArgument::Quoted, fakeLineNo },
{ newValue ? newValue : "", cmListFileArgument::Quoted, fakeLineNo },
{ *currentListFile, cmListFileArgument::Quoted, fakeLineNo },
{ stack, cmListFileArgument::Quoted, fakeLineNo }
};
- newLFF.Name = data->Command;
- newLFF.Line = fakeLineNo;
+
+ cmListFileFunction newLFF{ data->Command, fakeLineNo,
+ std::move(newLFFArgs) };
cmExecutionStatus status(*makefile);
if (!makefile->ExecuteCommand(newLFF, status)) {
cmSystemTools::Error(
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 2c7a8a7..327c1c7 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -54,7 +54,7 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
bool cmWhileFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile&) const
{
- return lff.Arguments.empty() || lff.Arguments == this->Args;
+ return lff.Arguments().empty() || lff.Arguments() == this->Args;
}
bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
diff --git a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake
index 5f5f7f5..6becc3c 100644
--- a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake
@@ -2,3 +2,4 @@ include(RunCMake)
run_cmake(components)
run_cmake(missing-components)
+run_cmake(version-range)
diff --git a/Tests/RunCMake/FindSWIG/version-range.cmake b/Tests/RunCMake/FindSWIG/version-range.cmake
new file mode 100644
index 0000000..7ba1134
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/version-range.cmake
@@ -0,0 +1,30 @@
+cmake_minimum_required (VERSION 3.18...3.19)
+
+find_package (SWIG)
+if (NOT SWIG_FOUND)
+ message (FATAL_ERROR "Failed to find SWIG")
+endif()
+
+# clean-up SWIG variables
+unset (SWIG_EXECUTABLE CACHE)
+unset (SWIG_DIR CACHE)
+
+## Specify a range including current SWIG version
+string (REGEX MATCH "^([0-9]+)" upper_version "${SWIG_VERSION}")
+math (EXPR upper_version "${upper_version} + 1")
+
+find_package (SWIG 1.0...${upper_version}.0)
+if (NOT SWIG_FOUND)
+ message (FATAL_ERROR "Failed to find SWIG with version range 1.0...${upper_version}.0")
+endif()
+
+# clean-up SWIG variables
+unset (SWIG_EXECUTABLE CACHE)
+unset (SWIG_DIR CACHE)
+
+## Specify a range excluding current SWIG version
+set (range 1.0...<${SWIG_VERSION})
+find_package (SWIG ${range})
+if (SWIG_FOUND)
+ message (FATAL_ERROR "Unexpectedly find SWIG with version range ${range}")
+endif()