Browse Source

cmake --build: prioritize --resolve-package-references over preset

Fixes: #23224
pull/348/head
Carsten Rudolph 4 years ago
committed by Brad King
parent
commit
f320a31087
  1. 21
      Help/manual/cmake-presets.7.rst
  2. 13
      Help/manual/cmake.1.rst
  3. 18
      Source/cmBuildOptions.h
  4. 2
      Source/cmGlobalVisualStudio10Generator.cxx
  5. 3
      Source/cmake.cxx
  6. 2
      Source/cmakemain.cxx

21
Help/manual/cmake-presets.7.rst

@ -498,17 +498,16 @@ that may contain the following fields:
.. note::
If this setting is not specified in a preset, CMake will instead
use the setting specified by the ``--resolve-package-references``
command line parameter. If the command line parameter is not
provided either, an environment-specific cache variable will be
evaluated to decide, if package restoration should be performed.
When using the Visual Studio generator, package references are
defined using the :prop_tgt:`VS_PACKAGE_REFERENCES` property.
Package references are restored using NuGet. It can be disabled
by setting the ``CMAKE_VS_NUGET_PACKAGE_RESTORE`` variable to
``OFF``. This can also be done from within a configure preset.
The command line parameter ``--resolve-package-references`` will take
priority over this setting. If the command line parameter is not provided
and this setting is not specified, an environment-specific cache variable
will be evaluated to decide, if package restoration should be performed.
When using the Visual Studio generator, package references are defined
using the :prop_tgt:`VS_PACKAGE_REFERENCES` property. Package references
are restored using NuGet. It can be disabled by setting the
``CMAKE_VS_NUGET_PACKAGE_RESTORE`` variable to ``OFF``. This can also be
done from within a configure preset.
``verbose``

13
Help/manual/cmake.1.rst

@ -472,16 +472,15 @@ following options:
target. When set to ``only``, the packages will be restored, but no build
will be performed. When set to ``off``, no packages will be restored.
If the target does not define any package references, this option does
nothing.
If the target does not define any package references, this option does nothing.
This setting can be specified in a build preset (using
``resolvePackageReferences``). In this case, the command line option will
be ignored.
``resolvePackageReferences``). The preset setting will be ignored, if this
command line option is specified.
If the no command line parameter or preset option is not provided, an
environment-specific cache variable will be evaluated to decide, if package
restoration should be performed.
If no command line parameter or preset option are provided, an environment-
specific cache variable will be evaluated to decide, if package restoration
should be performed.
When using the Visual Studio generator, package references are defined
using the :prop_tgt:`VS_PACKAGE_REFERENCES` property. Package references

18
Source/cmBuildOptions.h

@ -7,20 +7,20 @@
/** \brief Defines how to resolve packages **/
enum class PackageResolveMode
{
/** \brief Defines behavior based on cache variable (e.g.
/** \brief Behavior is defined by preset or cache variable (e.g.
CMAKE_VS_NUGET_PACKAGE_RESTORE). This is the default. **/
FromCacheVariable,
Default,
/** \brief Ignore behavior defined by cache variable and forces packages to
be resolved prior to build. **/
/** \brief Ignore behavior defined by preset or cache variable and forces
packages to be resolved prior to build. **/
Force,
/** \brief Ignore behavior defined by cache variable and forces packages to
be resolved, but skip the actual build. **/
/** \brief Ignore behavior defined by preset or cache variable and forces
packages to be resolved, but skip the actual build. **/
OnlyResolve,
/** \brief Ignore behavior defined by cache variable and dont resolve any
packages **/
/** \brief Ignore behavior defined by preset or cache variable and don't
resolve any packages **/
Disable
};
@ -40,5 +40,5 @@ public:
bool Clean = false;
bool Fast = false;
PackageResolveMode ResolveMode = PackageResolveMode::FromCacheVariable;
PackageResolveMode ResolveMode = PackageResolveMode::Default;
};

2
Source/cmGlobalVisualStudio10Generator.cxx

@ -1222,7 +1222,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
"Studio 2017 and later. You have to manually restore the "
"packages using NuGet before building the project.");
restorePackages = false;
} else if (restoreMode == PackageResolveMode::FromCacheVariable) {
} else if (restoreMode == PackageResolveMode::Default) {
// Decide if a restore is performed, based on a cache variable.
if (cmValue cached =
this->CMakeInstance->GetState()->GetCacheEntryValue(

3
Source/cmake.cxx

@ -3356,7 +3356,8 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
buildOptions.Clean = *expandedPreset->CleanFirst;
}
if (expandedPreset->ResolvePackageReferences) {
if (buildOptions.ResolveMode == PackageResolveMode::Default &&
expandedPreset->ResolvePackageReferences) {
buildOptions.ResolveMode = *expandedPreset->ResolvePackageReferences;
}

2
Source/cmakemain.cxx

@ -447,7 +447,7 @@ int do_build(int ac, char const* const* av)
bool cleanFirst = false;
bool foundClean = false;
bool foundNonClean = false;
PackageResolveMode resolveMode = PackageResolveMode::FromCacheVariable;
PackageResolveMode resolveMode = PackageResolveMode::Default;
bool verbose = cmSystemTools::HasEnv("VERBOSE");
std::string presetName;
bool listPresets = false;

Loading…
Cancel
Save