summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/os-macos.yml12
-rw-r--r--Help/manual/cmake-presets.7.rst36
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/manual/cmake.1.rst24
-rw-r--r--Help/manual/presets/schema.json61
-rw-r--r--Help/release/3.22.rst13
-rw-r--r--Help/release/dev/vs-package-restore.rst13
-rw-r--r--Help/variable/CMAKE_VS_NUGET_PACKAGE_RESTORE.rst22
-rw-r--r--Modules/CMakeCCompilerId.c.in2
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in2
-rw-r--r--Modules/ExternalProject.cmake373
-rw-r--r--Modules/ExternalProject/RepositoryInfo.txt.in (renamed from Modules/RepositoryInfo.txt.in)0
-rw-r--r--Modules/ExternalProject/cfgcmd.txt.in1
-rw-r--r--Modules/ExternalProject/download.cmake.in (renamed from Modules/ExternalProject-download.cmake.in)0
-rw-r--r--Modules/ExternalProject/extractfile.cmake.in65
-rw-r--r--Modules/ExternalProject/gitclone.cmake.in73
-rw-r--r--Modules/ExternalProject/gitupdate.cmake.in (renamed from Modules/ExternalProject-gitupdate.cmake.in)0
-rw-r--r--Modules/ExternalProject/hgclone.cmake.in49
-rw-r--r--Modules/ExternalProject/mkdirs.cmake.in19
-rw-r--r--Modules/ExternalProject/verify.cmake.in (renamed from Modules/ExternalProject-verify.cmake.in)0
-rw-r--r--Modules/FindCUDAToolkit.cmake4
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx6
-rw-r--r--Source/cmBuildOptions.h44
-rw-r--r--Source/cmCMakePresetsGraph.cxx3
-rw-r--r--Source/cmCMakePresetsGraph.h3
-rw-r--r--Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx35
-rw-r--r--Source/cmFileAPIToolchains.cxx41
-rw-r--r--Source/cmGeneratorTarget.cxx20
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.cxx7
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h3
-rw-r--r--Source/cmGlobalGenerator.cxx22
-rw-r--r--Source/cmGlobalGenerator.h8
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx3
-rw-r--r--Source/cmGlobalGhsMultiGenerator.h4
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.cxx7
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.h3
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.cxx7
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h3
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.h4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h4
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx83
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h3
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.cxx7
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.h4
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
-rw-r--r--Source/cmStandardLevelResolver.cxx5
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx40
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h1
-rw-r--r--Source/cm_utf8.c5
-rw-r--r--Source/cmake.cxx15
-rw-r--r--Source/cmake.h5
-rw-r--r--Source/cmakemain.cxx27
-rw-r--r--Source/kwsys/CMakeLists.txt1
-rw-r--r--Source/kwsys/Directory.cxx90
-rw-r--r--Source/kwsys/Directory.hxx.in21
-rw-r--r--Source/kwsys/Glob.cxx4
-rw-r--r--Source/kwsys/SystemTools.cxx21
-rw-r--r--Source/kwsys/SystemTools.hxx.in10
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good.json.in8
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128Common.cmake (renamed from Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake)1
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake (renamed from Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake)0
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake2
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake (renamed from Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake)0
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake1
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake (renamed from Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake)0
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake2
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake12
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake1
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake2
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake2
-rw-r--r--Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake9
-rw-r--r--Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake9
-rw-r--r--Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake36
-rw-r--r--Tests/RunCMake/ExternalProject/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt17
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs9
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Program.cs14
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata5
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkgbin0 -> 5664 bytes
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha5121
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec11
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake9
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/nuget.config.in7
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt1
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt1
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt1
-rw-r--r--Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt1
101 files changed, 1159 insertions, 388 deletions
diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml
index 66bbbf3..b0844cb 100644
--- a/.gitlab/os-macos.yml
+++ b/.gitlab/os-macos.yml
@@ -7,7 +7,7 @@
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci ext/$CI_CONCURRENT_ID"
# TODO: Factor this out so that each job selects the Xcode version to
# use so that different versions can be tested in a single pipeline.
- DEVELOPER_DIR: "/Applications/Xcode-13.1.app/Contents/Developer"
+ DEVELOPER_DIR: "/Applications/Xcode-13.2.app/Contents/Developer"
# Avoid conflicting with other projects running on the same machine.
SCCACHE_SERVER_PORT: 4227
@@ -87,7 +87,7 @@
- cmake # Since this is a bare runner, pin to a project.
- macos
- shell
- - xcode-13.1
+ - xcode-13.2
- nonconcurrent
.macos_x86_64_builder_tags_package:
@@ -95,7 +95,7 @@
- cmake # Since this is a bare runner, pin to a project.
- macos
- shell
- - xcode-13.1
+ - xcode-13.2
- nonconcurrent
- finder
@@ -104,7 +104,7 @@
- cmake # Since this is a bare runner, pin to a project.
- macos
- shell
- - xcode-13.1
+ - xcode-13.2
- concurrent
.macos_arm64_builder_tags:
@@ -112,7 +112,7 @@
- cmake # Since this is a bare runner, pin to a project.
- macos-arm64
- shell
- - xcode-13.1
+ - xcode-13.2
- nonconcurrent
.macos_arm64_builder_ext_tags:
@@ -120,7 +120,7 @@
- cmake # Since this is a bare runner, pin to a project.
- macos-arm64
- shell
- - xcode-13.1
+ - xcode-13.2
- concurrent
## macOS-specific scripts
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst
index e702d97..31bd9c0 100644
--- a/Help/manual/cmake-presets.7.rst
+++ b/Help/manual/cmake-presets.7.rst
@@ -474,6 +474,42 @@ that may contain the following fields:
An optional bool. If true, equivalent to passing ``--clean-first`` on
the command line.
+``resolvePackageReferences``
+
+ An optional string that specifies the package resolve mode. This is
+ allowed in preset files specifying version ``4`` or above.
+
+ This field overwrites the ``--resolve-package-references`` command line
+ parameter. If there are no targets that define package references, this
+ option does nothing. Valid values are:
+
+ ``on``
+
+ Causes package references to be resolved before attempting a build.
+
+ ``off``
+
+ Package references will not be resolved. Note that this may cause
+ errors in some build environments, such as .NET SDK style projects.
+
+ ``only``
+
+ Only resolve package references, but do not perform a build.
+
+ .. 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.
+
``verbose``
An optional bool. If true, equivalent to passing ``--verbose`` on the
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 920bfe0..04c5a53 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -119,6 +119,7 @@ Variables that Provide Information
/variable/CMAKE_VS_DEVENV_COMMAND
/variable/CMAKE_VS_MSBUILD_COMMAND
/variable/CMAKE_VS_NsightTegra_VERSION
+ /variable/CMAKE_VS_NUGET_PACKAGE_RESTORE
/variable/CMAKE_VS_PLATFORM_NAME
/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT
/variable/CMAKE_VS_PLATFORM_TOOLSET
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 04e2eda..1463f0a 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -463,6 +463,30 @@ following options:
Build target ``clean`` first, then build.
(To clean only, use ``--target clean``.)
+``--resolve-package-references=<on|off|only>``
+ .. versionadded:: 3.23
+
+ Resolve remote package references (e.g. NuGet packages) before build.
+ When set to ``on`` (default), packages will be restored before building a
+ 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.
+
+ This setting can be specified in a build preset (using
+ ``resolvePackageReferences``). In this case, the command line option will
+ be ignored.
+
+ 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.
+
+ 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``.
+
``--use-stderr``
Ignored. Behavior is default in CMake >= 3.0.
diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json
index 327291d..12f8b5e 100644
--- a/Help/manual/presets/schema.json
+++ b/Help/manual/presets/schema.json
@@ -52,7 +52,7 @@
"cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
"vendor": { "$ref": "#/definitions/vendor" },
"configurePresets": { "$ref": "#/definitions/configurePresetsV3"},
- "buildPresets": { "$ref": "#/definitions/buildPresetsV3"},
+ "buildPresets": { "$ref": "#/definitions/buildPresetsV4"},
"testPresets": { "$ref": "#/definitions/testPresetsV3"},
"include": { "$ref": "#/definitions/include"}
},
@@ -427,9 +427,25 @@
"additionalProperties": false
}
},
+ "buildPresetsItemsV4": {
+ "type": "array",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 4 and higher.",
+ "items": {
+ "type": "object",
+ "properties": {
+ "resolvePackageReferences": {
+ "type": "string",
+ "description": "An optional string specifying the package resolve behavior. Valid values are \"on\" (packages are resolved prior to the build), \"off\" (packages are not resolved prior to the build), and \"only\" (packages are resolved, but no build will be performed).",
+ "enum": [
+ "on", "off", "only"
+ ]
+ }
+ }
+ }
+ },
"buildPresetsItemsV3": {
"type": "array",
- "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 3 and higher.",
"items": {
"type": "object",
"properties": {
@@ -558,9 +574,44 @@
]
}
},
+ "buildPresetsV4": {
+ "type": "array",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 4 and higher.",
+ "allOf": [
+ { "$ref": "#/definitions/buildPresetsItemsV4" },
+ { "$ref": "#/definitions/buildPresetsItemsV3" },
+ { "$ref": "#/definitions/buildPresetsItemsV2" }
+ ],
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "configurePreset": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "inheritConfigureEnvironment": {},
+ "environment": {},
+ "jobs": {},
+ "targets": {},
+ "configuration": {},
+ "cleanFirst": {},
+ "resolvePackageReferences": {},
+ "verbose": {},
+ "nativeToolOptions": {},
+ "condition": {}
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false
+ }
+ },
"buildPresetsV3": {
"type": "array",
- "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 3 and higher.",
"allOf": [
{ "$ref": "#/definitions/buildPresetsItemsV3" },
{ "$ref": "#/definitions/buildPresetsItemsV2" }
@@ -624,7 +675,7 @@
},
"testPresetsItemsV3": {
"type": "array",
- "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher.",
"items": {
"type": "object",
"properties": {
@@ -949,7 +1000,7 @@
},
"testPresetsV3": {
"type": "array",
- "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher.",
"allOf": [
{ "$ref": "#/definitions/testPresetsItemsV2" },
{ "$ref": "#/definitions/testPresetsItemsV3" }
diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst
index fcb655d..a82d396 100644
--- a/Help/release/3.22.rst
+++ b/Help/release/3.22.rst
@@ -142,3 +142,16 @@ Other Changes
This became available as of VS 16.10 (toolchain version 14.29.30037).
* The :cpack_gen:`CPack NSIS Generator` now requires NSIS 3.03 or later.
+
+3.22.1
+------
+
+This version made no changes to documented features or interfaces.
+Some implementation updates were made to support ecosystem changes
+and/or fix regressions.
+
+3.22.2
+------
+
+* The ``OLD`` behavior of :policy:`CMP0128` was fixed to add flags even when
+ the specified standard matches the compiler default.
diff --git a/Help/release/dev/vs-package-restore.rst b/Help/release/dev/vs-package-restore.rst
new file mode 100644
index 0000000..e8b5f0c
--- /dev/null
+++ b/Help/release/dev/vs-package-restore.rst
@@ -0,0 +1,13 @@
+vs-package-restore
+------------------
+
+* Targets with :prop_tgt:`VS_PACKAGE_REFERENCES` will now automatically attempt
+ to restore the package references from NuGet. The cache variable
+ :variable:`CMAKE_VS_NUGET_PACKAGE_RESTORE` was added to toggle automatic
+ package restore off.
+
+* :manual:`cmake(1)` gained the ``--resolve-package-references=<on|off|only>``
+ command-line option to control automatic package restoration.
+
+* :manual:`cmake-presets(7)` gained support for specifying the
+ ``resolvePackageReferences`` command line option in a build preset.
diff --git a/Help/variable/CMAKE_VS_NUGET_PACKAGE_RESTORE.rst b/Help/variable/CMAKE_VS_NUGET_PACKAGE_RESTORE.rst
new file mode 100644
index 0000000..7160726
--- /dev/null
+++ b/Help/variable/CMAKE_VS_NUGET_PACKAGE_RESTORE.rst
@@ -0,0 +1,22 @@
+CMAKE_VS_NUGET_PACKAGE_RESTORE
+------------------------------
+
+.. versionadded:: 3.23
+
+When using a Visual Studio generator, this cache variable controls
+if msbuild should automatically attempt to restore NuGet packages
+prior to a build. NuGet packages can be defined using the
+:prop_tgt:`VS_PACKAGE_REFERENCES` property on a target. If no
+package references are defined, this setting will do nothing.
+
+The command line option ``--resolve-package-references`` can be used
+alternatively to control the resolve behavior globally. This option
+will take precedence over the cache variable.
+
+Targets that use the :prop_tgt:`DOTNET_SDK` are required to run a
+restore before building. Disabling this option may cause the build
+to fail in such projects.
+
+This setting is stored as a cache entry. Default value is ``ON``.
+
+See also the :prop_tgt:`VS_PACKAGE_REFERENCES` property.
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 30ad9824..0cb8724 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -61,7 +61,7 @@ const char* info_language_standard_default =
const char* info_language_extensions_default = "INFO" ":" "extensions_default["
/* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */
-#if (defined(__clang__) || defined(__GNUC__) || \
+#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \
defined(__TI_COMPILER_VERSION__)) && \
!defined(__STRICT_ANSI__) && !defined(_MSC_VER)
"ON"
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index e7a5487..4904249 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -67,7 +67,7 @@ const char* info_language_standard_default = "INFO" ":" "standard_default["
const char* info_language_extensions_default = "INFO" ":" "extensions_default["
/* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */
-#if (defined(__clang__) || defined(__GNUC__) || \
+#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \
defined(__TI_COMPILER_VERSION__)) && \
!defined(__STRICT_ANSI__) && !defined(_MSC_VER)
"ON"
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index fc15a0f..411a1a9 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1254,7 +1254,25 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
"ExternalProject module."
)
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+function(_ep_write_gitclone_script
+ script_filename
+ source_dir
+ git_EXECUTABLE
+ git_repository
+ git_tag
+ git_remote_name
+ init_submodules
+ git_submodules_recurse
+ git_submodules
+ git_shallow
+ git_progress
+ git_config
+ src_name
+ work_dir
+ gitclone_infofile
+ gitclone_stampfile
+ tls_verify)
+
if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5)
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set(git_checkout_explicit-- "--")
@@ -1300,136 +1318,48 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git
endif()
string (REPLACE ";" " " git_options "${git_options}")
- file(WRITE ${script_filename}
-"
-if(EXISTS \"${gitclone_stampfile}\" AND EXISTS \"${gitclone_infofile}\" AND
- \"${gitclone_stampfile}\" IS_NEWER_THAN \"${gitclone_infofile}\")
- message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\")
- return()
-endif()
-
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
-endif()
-
-# try the clone 3 times in case there is an odd git clone issue
-set(error_code 1)
-set(number_of_tries 0)
-while(error_code AND number_of_tries LESS 3)
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} clone ${git_clone_options} \"${git_repository}\" \"${src_name}\"
- WORKING_DIRECTORY \"${work_dir}\"
- RESULT_VARIABLE error_code
- )
- math(EXPR number_of_tries \"\${number_of_tries} + 1\")
-endwhile()
-if(number_of_tries GREATER 1)
- message(STATUS \"Had to git clone more than once:
- \${number_of_tries} times.\")
-endif()
-if(error_code)
- message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\")
-endif()
-
-execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} checkout ${git_tag} ${git_checkout_explicit--}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
-endif()
-
-set(init_submodules ${init_submodules})
-if(init_submodules)
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update ${git_submodules_recurse} --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-endif()
-if(error_code)
- message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
-endif()
-
-# Complete success, update the script-last-run stamp file:
-#
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E copy
- \"${gitclone_infofile}\"
- \"${gitclone_stampfile}\"
- RESULT_VARIABLE error_code
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/gitclone.cmake.in
+ ${script_filename}
+ @ONLY
)
-if(error_code)
- message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${gitclone_stampfile}'\")
-endif()
-
-"
-)
-
endfunction()
-function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir hgclone_infofile hgclone_stampfile)
+function(_ep_write_hgclone_script
+ script_filename
+ source_dir
+ hg_EXECUTABLE
+ hg_repository
+ hg_tag
+ src_name
+ work_dir
+ hgclone_infofile
+ hgclone_stampfile)
+
if("${hg_tag}" STREQUAL "")
message(FATAL_ERROR "Tag for hg checkout should not be empty.")
endif()
- file(WRITE ${script_filename}
-"
-if(EXISTS \"${hgclone_stampfile}\" AND EXISTS \"${hgclone_infofile}\" AND
- \"${hgclone_stampfile}\" IS_NEWER_THAN \"${hgclone_infofile}\")
- message(STATUS \"Avoiding repeated hg clone, stamp file is up to date: '${hgclone_stampfile}'\")
- return()
-endif()
-
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
-endif()
-execute_process(
- COMMAND \"${hg_EXECUTABLE}\" clone -U \"${hg_repository}\" \"${src_name}\"
- WORKING_DIRECTORY \"${work_dir}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to clone repository: '${hg_repository}'\")
-endif()
-
-execute_process(
- COMMAND \"${hg_EXECUTABLE}\" update ${hg_tag}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to checkout tag: '${hg_tag}'\")
-endif()
-
-# Complete success, update the script-last-run stamp file:
-#
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E copy
- \"${hgclone_infofile}\"
- \"${hgclone_stampfile}\"
- RESULT_VARIABLE error_code
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/hgclone.cmake.in
+ ${script_filename}
+ @ONLY
)
-if(error_code)
- message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${hgclone_stampfile}'\")
-endif()
-
-"
-)
-
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_repository work_dir git_update_strategy)
+function(_ep_write_gitupdate_script
+ script_filename
+ git_EXECUTABLE
+ git_tag
+ git_remote_name
+ init_submodules
+ git_submodules_recurse
+ git_submodules
+ git_repository
+ work_dir
+ git_update_strategy)
+
if("${git_tag}" STREQUAL "")
message(FATAL_ERROR "Tag for git checkout should not be empty.")
endif()
@@ -1443,13 +1373,27 @@ function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_r
endif()
configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject-gitupdate.cmake.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/gitupdate.cmake.in"
"${script_filename}"
@ONLY
)
endfunction()
-function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inactivity_timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file)
+function(_ep_write_downloadfile_script
+ script_filename
+ REMOTE
+ LOCAL
+ timeout
+ inactivity_timeout
+ no_progress
+ hash
+ tls_verify
+ tls_cainfo
+ userpwd
+ http_headers
+ netrc
+ netrc_file)
+
if(timeout)
set(TIMEOUT_ARGS TIMEOUT ${timeout})
set(TIMEOUT_MSG "${timeout} seconds")
@@ -1465,7 +1409,6 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inac
set(INACTIVITY_TIMEOUT_MSG "none")
endif()
-
if(no_progress)
set(SHOW_PROGRESS "")
else()
@@ -1553,7 +1496,7 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inac
# * USERPWD_ARGS
# * HTTP_HEADERS_ARGS
configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject-download.cmake.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/download.cmake.in"
"${script_filename}"
@ONLY
)
@@ -1574,7 +1517,7 @@ function(_ep_write_verifyfile_script script_filename LOCAL hash)
# * EXPECT_VALUE
# * LOCAL
configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject-verify.cmake.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/verify.cmake.in"
"${script_filename}"
@ONLY
)
@@ -1597,68 +1540,11 @@ function(_ep_write_extractfile_script script_filename name filename directory)
return()
endif()
- file(WRITE ${script_filename}
-"# Make file names absolute:
-#
-get_filename_component(filename \"${filename}\" ABSOLUTE)
-get_filename_component(directory \"${directory}\" ABSOLUTE)
-
-message(STATUS \"extracting...
- src='\${filename}'
- dst='\${directory}'\")
-
-if(NOT EXISTS \"\${filename}\")
- message(FATAL_ERROR \"error: file to extract does not exist: '\${filename}'\")
-endif()
-
-# Prepare a space for extracting:
-#
-set(i 1234)
-while(EXISTS \"\${directory}/../ex-${name}\${i}\")
- math(EXPR i \"\${i} + 1\")
-endwhile()
-set(ut_dir \"\${directory}/../ex-${name}\${i}\")
-file(MAKE_DIRECTORY \"\${ut_dir}\")
-
-# Extract it:
-#
-message(STATUS \"extracting... [tar ${args}]\")
-execute_process(COMMAND \${CMAKE_COMMAND} -E tar ${args} \${filename}
- WORKING_DIRECTORY \${ut_dir}
- RESULT_VARIABLE rv)
-
-if(NOT rv EQUAL 0)
- message(STATUS \"extracting... [error clean up]\")
- file(REMOVE_RECURSE \"\${ut_dir}\")
- message(FATAL_ERROR \"error: extract of '\${filename}' failed\")
-endif()
-
-# Analyze what came out of the tar file:
-#
-message(STATUS \"extracting... [analysis]\")
-file(GLOB contents \"\${ut_dir}/*\")
-list(REMOVE_ITEM contents \"\${ut_dir}/.DS_Store\")
-list(LENGTH contents n)
-if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
- set(contents \"\${ut_dir}\")
-endif()
-
-# Move \"the one\" directory to the final directory:
-#
-message(STATUS \"extracting... [rename]\")
-file(REMOVE_RECURSE \${directory})
-get_filename_component(contents \${contents} ABSOLUTE)
-file(RENAME \${contents} \${directory})
-
-# Clean up:
-#
-message(STATUS \"extracting... [clean up]\")
-file(REMOVE_RECURSE \"\${ut_dir}\")
-
-message(STATUS \"extracting... done\")
-"
-)
-
+ configure_file(
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/extractfile.cmake.in"
+ "${script_filename}"
+ @ONLY
+ )
endfunction()
@@ -1674,6 +1560,7 @@ function(_ep_set_directories name)
endif()
endif()
if(prefix)
+ file(TO_CMAKE_PATH "${prefix}" prefix)
set(tmp_default "${prefix}/tmp")
set(download_default "${prefix}/src")
set(source_default "${prefix}/src/${name}")
@@ -1681,6 +1568,7 @@ function(_ep_set_directories name)
set(stamp_default "${prefix}/src/${name}-stamp")
set(install_default "${prefix}")
else()
+ file(TO_CMAKE_PATH "${base}" base)
set(tmp_default "${base}/tmp/${name}")
set(download_default "${base}/Download/${name}")
set(source_default "${base}/Source/${name}")
@@ -1709,6 +1597,7 @@ function(_ep_set_directories name)
if(NOT IS_ABSOLUTE "${${var}_dir}")
get_filename_component(${var}_dir "${top}/${${var}_dir}" ABSOLUTE)
endif()
+ file(TO_CMAKE_PATH "${${var}_dir}" ${var}_dir)
set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
endforeach()
@@ -1720,6 +1609,7 @@ function(_ep_set_directories name)
if(NOT IS_ABSOLUTE "${log_dir}")
get_filename_component(log_dir "${top}/${log_dir}" ABSOLUTE)
endif()
+ file(TO_CMAKE_PATH "${log_dir}" log_dir)
set_property(TARGET ${name} PROPERTY _EP_LOG_DIR "${log_dir}")
get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR)
@@ -1731,6 +1621,7 @@ function(_ep_set_directories name)
else()
# Prefix with a slash so that when appended to the source directory, it
# behaves as expected.
+ file(TO_CMAKE_PATH "${source_subdir}" source_subdir)
set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "/${source_subdir}")
endif()
if(build_in_source)
@@ -1742,22 +1633,19 @@ function(_ep_set_directories name)
endif()
endif()
- # Make the directories at CMake configure time *and* add a custom command
- # to make them at build time. They need to exist at makefile generation
- # time for Borland make and wmake so that CMake may generate makefiles
- # with "cd C:\short\paths\with\no\spaces" commands in them.
- #
- # Additionally, the add_custom_command is still used in case somebody
- # removes one of the necessary directories and tries to rebuild without
- # re-running cmake.
- foreach(var ${places})
- string(TOUPPER "${var}" VAR)
- get_property(dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
- file(MAKE_DIRECTORY "${dir}")
- if(NOT EXISTS "${dir}")
- message(FATAL_ERROR "dir '${dir}' does not exist after file(MAKE_DIRECTORY)")
- endif()
- endforeach()
+ # This script will be used both here and by the mkdir step. We create the
+ # directories now at configure time and ensure they exist again at build
+ # time (since somebody might remove one of the required directories and try
+ # to rebuild without re-running cmake). They need to exist now at makefile
+ # generation time for Borland make and wmake so that CMake may generate
+ # makefiles with "cd C:\short\paths\with\no\spaces" commands in them.
+ set(script_filename "${tmp_dir}/${name}-mkdirs.cmake")
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/mkdirs.cmake.in
+ ${script_filename}
+ @ONLY
+ )
+ include(${script_filename})
endfunction()
@@ -2523,22 +2411,14 @@ endfunction()
function(_ep_add_mkdir_command name)
- ExternalProject_Get_Property(${name}
- source_dir binary_dir install_dir stamp_dir download_dir tmp_dir log_dir)
-
- _ep_get_configuration_subdir_suffix(cfgdir)
+ ExternalProject_Get_Property(${name} tmp_dir)
+ set(script_filename "${tmp_dir}/${name}-mkdirs.cmake")
ExternalProject_Add_Step(${name} mkdir
INDEPENDENT TRUE
COMMENT "Creating directories for '${name}'"
- COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${binary_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${tmp_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${stamp_dir}${cfgdir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${download_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${log_dir}
- )
+ COMMAND ${CMAKE_COMMAND} -P ${script_filename}
+ )
endfunction()
@@ -2613,7 +2493,7 @@ function(_ep_add_download_command name)
set(module ${cvs_module})
set(tag ${cvs_tag})
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-cvsinfo.txt"
@ONLY
)
@@ -2638,7 +2518,7 @@ function(_ep_add_download_command name)
set(module)
set(tag ${svn_revision})
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-svninfo.txt"
@ONLY
)
@@ -2714,7 +2594,7 @@ function(_ep_add_download_command name)
set(module)
set(tag ${git_remote_name})
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-gitinfo.txt"
@ONLY
)
@@ -2754,7 +2634,7 @@ function(_ep_add_download_command name)
set(module)
set(tag)
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-hginfo.txt"
@ONLY
)
@@ -2795,7 +2675,7 @@ function(_ep_add_download_command name)
set(module "${url}")
set(tag "${hash}")
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-urlinfo.txt"
@ONLY
)
@@ -2850,7 +2730,21 @@ function(_ep_add_download_command name)
get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD)
get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER)
set(download_script "${stamp_dir}/download-${name}.cmake")
- _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${inactivity_timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}")
+ _ep_write_downloadfile_script(
+ "${download_script}"
+ "${url}"
+ "${file}"
+ "${timeout}"
+ "${inactivity_timeout}"
+ "${no_progress}"
+ "${hash}"
+ "${tls_verify}"
+ "${tls_cainfo}"
+ "${http_username}:${http_password}"
+ "${http_headers}"
+ "${netrc}"
+ "${netrc_file}"
+ )
set(cmd ${CMAKE_COMMAND} -P "${download_script}"
COMMAND)
if (no_extract)
@@ -2868,11 +2762,20 @@ function(_ep_add_download_command name)
set(steps "verify and extract")
endif ()
set(comment "Performing download step (${steps}) for '${name}'")
- _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}")
+ _ep_write_verifyfile_script(
+ "${stamp_dir}/verify-${name}.cmake"
+ "${file}"
+ "${hash}"
+ )
endif()
list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake)
if (NOT no_extract)
- _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
+ _ep_write_extractfile_script(
+ "${stamp_dir}/extract-${name}.cmake"
+ "${name}"
+ "${file}"
+ "${source_dir}"
+ )
list(APPEND cmd COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
else ()
set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file})
@@ -3035,9 +2938,18 @@ function(_ep_add_update_command name)
_ep_get_git_submodules_recurse(git_submodules_recurse)
- _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
- ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules_recurse}" "${git_submodules}" ${git_repository} ${work_dir} ${git_update_strategy}
- )
+ _ep_write_gitupdate_script(
+ "${tmp_dir}/${name}-gitupdate.cmake"
+ "${GIT_EXECUTABLE}"
+ "${git_tag}"
+ "${git_remote_name}"
+ "${git_init_submodules}"
+ "${git_submodules_recurse}"
+ "${git_submodules}"
+ "${git_repository}"
+ "${work_dir}"
+ "${git_update_strategy}"
+ )
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)
elseif(hg_repository)
@@ -3279,10 +3191,11 @@ function(_ep_add_configure_command name)
# used, cmake args or cmake generator) then re-run the configure step.
# Fixes issue https://gitlab.kitware.com/cmake/cmake/-/issues/10258
#
- if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in)
- file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='\@cmd\@'\n")
- endif()
- configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/cfgcmd.txt.in
+ ${tmp_dir}/${name}-cfgcmd.txt
+ @ONLY
+ )
list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)
list(APPEND file_deps ${_ep_cache_args_script})
diff --git a/Modules/RepositoryInfo.txt.in b/Modules/ExternalProject/RepositoryInfo.txt.in
index df8e322..df8e322 100644
--- a/Modules/RepositoryInfo.txt.in
+++ b/Modules/ExternalProject/RepositoryInfo.txt.in
diff --git a/Modules/ExternalProject/cfgcmd.txt.in b/Modules/ExternalProject/cfgcmd.txt.in
new file mode 100644
index 0000000..b3f09ef
--- /dev/null
+++ b/Modules/ExternalProject/cfgcmd.txt.in
@@ -0,0 +1 @@
+cmd='@cmd@'
diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject/download.cmake.in
index ff8c659..ff8c659 100644
--- a/Modules/ExternalProject-download.cmake.in
+++ b/Modules/ExternalProject/download.cmake.in
diff --git a/Modules/ExternalProject/extractfile.cmake.in b/Modules/ExternalProject/extractfile.cmake.in
new file mode 100644
index 0000000..d7f5756
--- /dev/null
+++ b/Modules/ExternalProject/extractfile.cmake.in
@@ -0,0 +1,65 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+# Make file names absolute:
+#
+get_filename_component(filename "@filename@" ABSOLUTE)
+get_filename_component(directory "@directory@" ABSOLUTE)
+
+message(STATUS "extracting...
+ src='${filename}'
+ dst='${directory}'"
+)
+
+if(NOT EXISTS "${filename}")
+ message(FATAL_ERROR "File to extract does not exist: '${filename}'")
+endif()
+
+# Prepare a space for extracting:
+#
+set(i 1234)
+while(EXISTS "${directory}/../ex-@name@${i}")
+ math(EXPR i "${i} + 1")
+endwhile()
+set(ut_dir "${directory}/../ex-@name@${i}")
+file(MAKE_DIRECTORY "${ut_dir}")
+
+# Extract it:
+#
+message(STATUS "extracting... [tar @args@]")
+execute_process(COMMAND ${CMAKE_COMMAND} -E tar @args@ ${filename}
+ WORKING_DIRECTORY ${ut_dir}
+ RESULT_VARIABLE rv
+)
+
+if(NOT rv EQUAL 0)
+ message(STATUS "extracting... [error clean up]")
+ file(REMOVE_RECURSE "${ut_dir}")
+ message(FATAL_ERROR "Extract of '${filename}' failed")
+endif()
+
+# Analyze what came out of the tar file:
+#
+message(STATUS "extracting... [analysis]")
+file(GLOB contents "${ut_dir}/*")
+list(REMOVE_ITEM contents "${ut_dir}/.DS_Store")
+list(LENGTH contents n)
+if(NOT n EQUAL 1 OR NOT IS_DIRECTORY "${contents}")
+ set(contents "${ut_dir}")
+endif()
+
+# Move "the one" directory to the final directory:
+#
+message(STATUS "extracting... [rename]")
+file(REMOVE_RECURSE ${directory})
+get_filename_component(contents ${contents} ABSOLUTE)
+file(RENAME ${contents} ${directory})
+
+# Clean up:
+#
+message(STATUS "extracting... [clean up]")
+file(REMOVE_RECURSE "${ut_dir}")
+
+message(STATUS "extracting... done")
diff --git a/Modules/ExternalProject/gitclone.cmake.in b/Modules/ExternalProject/gitclone.cmake.in
new file mode 100644
index 0000000..3312171
--- /dev/null
+++ b/Modules/ExternalProject/gitclone.cmake.in
@@ -0,0 +1,73 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+if(EXISTS "@gitclone_stampfile@" AND EXISTS "@gitclone_infofile@" AND
+ "@gitclone_stampfile@" IS_NEWER_THAN "@gitclone_infofile@")
+ message(STATUS
+ "Avoiding repeated git clone, stamp file is up to date: "
+ "'@gitclone_stampfile@'"
+ )
+ return()
+endif()
+
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E rm -rf "@source_dir@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to remove directory: '@source_dir@'")
+endif()
+
+# try the clone 3 times in case there is an odd git clone issue
+set(error_code 1)
+set(number_of_tries 0)
+while(error_code AND number_of_tries LESS 3)
+ execute_process(
+ COMMAND "@git_EXECUTABLE@" @git_options@
+ clone @git_clone_options@ "@git_repository@" "@src_name@"
+ WORKING_DIRECTORY "@work_dir@"
+ RESULT_VARIABLE error_code
+ )
+ math(EXPR number_of_tries "${number_of_tries} + 1")
+endwhile()
+if(number_of_tries GREATER 1)
+ message(STATUS "Had to git clone more than once: ${number_of_tries} times.")
+endif()
+if(error_code)
+ message(FATAL_ERROR "Failed to clone repository: '@git_repository@'")
+endif()
+
+execute_process(
+ COMMAND "@git_EXECUTABLE@" @git_options@
+ checkout "@git_tag@" @git_checkout_explicit--@
+ WORKING_DIRECTORY "@work_dir@/@src_name@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to checkout tag: '@git_tag@'")
+endif()
+
+set(init_submodules @init_submodules@)
+if(init_submodules)
+ execute_process(
+ COMMAND "@git_EXECUTABLE@" @git_options@
+ submodule update @git_submodules_recurse@ --init @git_submodules@
+ WORKING_DIRECTORY "@work_dir@/@src_name@"
+ RESULT_VARIABLE error_code
+ )
+endif()
+if(error_code)
+ message(FATAL_ERROR "Failed to update submodules in: '@work_dir@/@src_name@'")
+endif()
+
+# Complete success, update the script-last-run stamp file:
+#
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "@gitclone_infofile@" "@gitclone_stampfile@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to copy script-last-run stamp file: '@gitclone_stampfile@'")
+endif()
diff --git a/Modules/ExternalProject-gitupdate.cmake.in b/Modules/ExternalProject/gitupdate.cmake.in
index 0de2372..0de2372 100644
--- a/Modules/ExternalProject-gitupdate.cmake.in
+++ b/Modules/ExternalProject/gitupdate.cmake.in
diff --git a/Modules/ExternalProject/hgclone.cmake.in b/Modules/ExternalProject/hgclone.cmake.in
new file mode 100644
index 0000000..e2b55ba
--- /dev/null
+++ b/Modules/ExternalProject/hgclone.cmake.in
@@ -0,0 +1,49 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+if(EXISTS "@hgclone_stampfile@" AND EXISTS "@hgclone_infofile@" AND
+ "@hgclone_stampfile@" IS_NEWER_THAN "@hgclone_infofile@")
+ message(STATUS
+ "Avoiding repeated hg clone, stamp file is up to date: "
+ "'@hgclone_stampfile@'"
+ )
+ return()
+endif()
+
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E rm -rf "@source_dir@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to remove directory: '@source_dir@'")
+endif()
+
+execute_process(
+ COMMAND "@hg_EXECUTABLE@" clone -U "@hg_repository@" "@src_name@"
+ WORKING_DIRECTORY "@work_dir@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to clone repository: '@hg_repository@'")
+endif()
+
+execute_process(
+ COMMAND "@hg_EXECUTABLE@" update @hg_tag@
+ WORKING_DIRECTORY "@work_dir@/@src_name@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to checkout tag: '@hg_tag@'")
+endif()
+
+# Complete success, update the script-last-run stamp file:
+#
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "@hgclone_infofile@" "@hgclone_stampfile@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to copy script-last-run stamp file: '@hgclone_stampfile@'")
+endif()
diff --git a/Modules/ExternalProject/mkdirs.cmake.in b/Modules/ExternalProject/mkdirs.cmake.in
new file mode 100644
index 0000000..d30a2e7
--- /dev/null
+++ b/Modules/ExternalProject/mkdirs.cmake.in
@@ -0,0 +1,19 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+file(MAKE_DIRECTORY
+ "@source_dir@"
+ "@binary_dir@"
+ "@install_dir@"
+ "@tmp_dir@"
+ "@stamp_dir@"
+ "@download_dir@"
+ "@log_dir@"
+)
+
+set(configSubDirs @CMAKE_CONFIGURATION_TYPES@)
+foreach(subDir IN LISTS configSubDirs)
+ file(MAKE_DIRECTORY "@stamp_dir@/${subDir}")
+endforeach()
diff --git a/Modules/ExternalProject-verify.cmake.in b/Modules/ExternalProject/verify.cmake.in
index c06da4e..c06da4e 100644
--- a/Modules/ExternalProject-verify.cmake.in
+++ b/Modules/ExternalProject/verify.cmake.in
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index d1cd38d..573f956 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -143,13 +143,11 @@ CUDA Driver Library
""""""""""""""""""""
The CUDA Driver library (cuda) are used by applications that use calls
-such as `cuMemAlloc`, and `cuMemFree`. This is generally used by advanced
-
+such as `cuMemAlloc`, and `cuMemFree`.
Targets Created:
- ``CUDA::cuda_driver``
-- ``CUDA::cuda_driver``
.. _`cuda_toolkit_cuBLAS`:
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index b31b8dc..ddcdd7e 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -155,6 +155,7 @@ set(SRCS
cmBinUtilsWindowsPELinker.h
cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h
+ cmBuildOptions.h
cmCacheManager.cxx
cmCacheManager.h
cmCLocaleEnvironmentScope.h
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 7d8f3aa..a376a0f 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 22)
-set(CMake_VERSION_PATCH 20220122)
+set(CMake_VERSION_PATCH 20220126)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index adfc8ef..e09b4dd 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -9,6 +9,7 @@
#include "cmsys/Process.h"
+#include "cmBuildOptions.h"
#include "cmCTest.h"
#include "cmCTestTestHandler.h"
#include "cmGlobalGenerator.h"
@@ -263,10 +264,13 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
if (!config) {
config = "Debug";
}
+
+ cmBuildOptions buildOptions(!this->BuildNoClean, false,
+ PackageResolveMode::Disable);
int retVal = cm.GetGlobalGenerator()->Build(
cmake::NO_BUILD_PARALLEL_LEVEL, this->SourceDir, this->BinaryDir,
this->BuildProject, { tar }, output, this->BuildMakeProgram, config,
- !this->BuildNoClean, false, false, remainingTime);
+ buildOptions, false, remainingTime);
out << output;
// if the build failed then return
if (retVal) {
diff --git a/Source/cmBuildOptions.h b/Source/cmBuildOptions.h
new file mode 100644
index 0000000..58baeef
--- /dev/null
+++ b/Source/cmBuildOptions.h
@@ -0,0 +1,44 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+/** \brief Defines how to resolve packages **/
+enum class PackageResolveMode
+{
+ /** \brief Defines behavior based on cache variable (e.g.
+ CMAKE_VS_NUGET_PACKAGE_RESTORE). This is the default. **/
+ FromCacheVariable,
+
+ /** \brief Ignore behavior defined by 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. **/
+ OnlyResolve,
+
+ /** \brief Ignore behavior defined by cache variable and dont resolve any
+ packages **/
+ Disable
+};
+
+struct cmBuildOptions
+{
+public:
+ cmBuildOptions() noexcept = default;
+ explicit cmBuildOptions(bool clean, bool fast,
+ PackageResolveMode resolveMode) noexcept
+ : Clean(clean)
+ , Fast(fast)
+ , ResolveMode(resolveMode)
+ {
+ }
+ explicit cmBuildOptions(const cmBuildOptions&) noexcept = default;
+ cmBuildOptions& operator=(const cmBuildOptions&) noexcept = default;
+
+ bool Clean = false;
+ bool Fast = false;
+ PackageResolveMode ResolveMode = PackageResolveMode::FromCacheVariable;
+};
diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx
index 238aa68..79e8191 100644
--- a/Source/cmCMakePresetsGraph.cxx
+++ b/Source/cmCMakePresetsGraph.cxx
@@ -724,6 +724,9 @@ cmCMakePresetsGraph::BuildPreset::VisitPresetInherit(
InheritOptionalValue(preset.CleanFirst, parent.CleanFirst);
InheritOptionalValue(preset.Verbose, parent.Verbose);
InheritVector(preset.NativeToolOptions, parent.NativeToolOptions);
+ if (!preset.ResolvePackageReferences) {
+ preset.ResolvePackageReferences = parent.ResolvePackageReferences;
+ }
return ReadFileResult::READ_OK;
}
diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h
index 8581809..d3a5cfc 100644
--- a/Source/cmCMakePresetsGraph.h
+++ b/Source/cmCMakePresetsGraph.h
@@ -14,6 +14,8 @@
#include <cm/optional>
+enum class PackageResolveMode;
+
class cmCMakePresetsGraph
{
public:
@@ -181,6 +183,7 @@ public:
cm::optional<bool> CleanFirst;
cm::optional<bool> Verbose;
std::vector<std::string> NativeToolOptions;
+ cm::optional<PackageResolveMode> ResolvePackageReferences;
ReadFileResult VisitPresetInherit(const Preset& parent) override;
ReadFileResult VisitPresetAfterInherit(int /* version */) override;
diff --git a/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx b/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
index ef605d1..eefe2fe 100644
--- a/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
+++ b/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
@@ -12,6 +12,7 @@
#include <cm3p/json/value.h>
+#include "cmBuildOptions.h"
#include "cmCMakePresetsGraph.h"
#include "cmCMakePresetsGraphInternal.h"
#include "cmJSONHelpers.h"
@@ -20,6 +21,37 @@ namespace {
using ReadFileResult = cmCMakePresetsGraph::ReadFileResult;
using BuildPreset = cmCMakePresetsGraph::BuildPreset;
+ReadFileResult PackageResolveModeHelper(cm::optional<PackageResolveMode>& out,
+ const Json::Value* value)
+{
+ if (!value) {
+ out = cm::nullopt;
+ return ReadFileResult::READ_OK;
+ }
+
+ if (!value->isString()) {
+ return ReadFileResult::INVALID_PRESET;
+ }
+
+ if (value->asString() == "on") {
+ out = PackageResolveMode::Force;
+ } else if (value->asString() == "off") {
+ out = PackageResolveMode::Disable;
+ } else if (value->asString() == "only") {
+ out = PackageResolveMode::OnlyResolve;
+ } else {
+ return ReadFileResult::INVALID_PRESET;
+ }
+
+ return ReadFileResult::READ_OK;
+}
+
+std::function<ReadFileResult(BuildPreset&, const Json::Value*)> const
+ ResolvePackageReferencesHelper =
+ [](BuildPreset& out, const Json::Value* value) -> ReadFileResult {
+ return PackageResolveModeHelper(out.ResolvePackageReferences, value);
+};
+
auto const BuildPresetHelper =
cmJSONObjectHelper<BuildPreset, ReadFileResult>(
ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false)
@@ -59,7 +91,8 @@ auto const BuildPresetHelper =
.Bind("nativeToolOptions"_s, &BuildPreset::NativeToolOptions,
cmCMakePresetsGraphInternal::PresetVectorStringHelper, false)
.Bind("condition"_s, &BuildPreset::ConditionEvaluator,
- cmCMakePresetsGraphInternal::PresetConditionHelper, false);
+ cmCMakePresetsGraphInternal::PresetConditionHelper, false)
+ .Bind("resolvePackageReferences"_s, ResolvePackageReferencesHelper, false);
}
namespace cmCMakePresetsGraphInternal {
diff --git a/Source/cmFileAPIToolchains.cxx b/Source/cmFileAPIToolchains.cxx
index b3540c9..fe2972f 100644
--- a/Source/cmFileAPIToolchains.cxx
+++ b/Source/cmFileAPIToolchains.cxx
@@ -30,10 +30,6 @@ class Toolchains
cmFileAPI& FileAPI;
unsigned long Version;
- static const std::vector<ToolchainVariable> CompilerVariables;
- static const std::vector<ToolchainVariable> CompilerImplicitVariables;
- static const ToolchainVariable SourceFileExtensionsVariable;
-
Json::Value DumpToolchains();
Json::Value DumpToolchain(std::string const& lang);
Json::Value DumpToolchainVariables(
@@ -48,24 +44,6 @@ public:
Json::Value Dump();
};
-const std::vector<ToolchainVariable> Toolchains::CompilerVariables{
- { "path", "COMPILER", false },
- { "id", "COMPILER_ID", false },
- { "version", "COMPILER_VERSION", false },
- { "target", "COMPILER_TARGET", false },
-};
-
-const std::vector<ToolchainVariable> Toolchains::CompilerImplicitVariables{
- { "includeDirectories", "IMPLICIT_INCLUDE_DIRECTORIES", true },
- { "linkDirectories", "IMPLICIT_LINK_DIRECTORIES", true },
- { "linkFrameworkDirectories", "IMPLICIT_LINK_FRAMEWORK_DIRECTORIES", true },
- { "linkLibraries", "IMPLICIT_LINK_LIBRARIES", true },
-};
-
-const ToolchainVariable Toolchains::SourceFileExtensionsVariable{
- "sourceFileExtensions", "SOURCE_FILE_EXTENSIONS", true
-};
-
Toolchains::Toolchains(cmFileAPI& fileAPI, unsigned long version)
: FileAPI(fileAPI)
, Version(version)
@@ -94,6 +72,25 @@ Json::Value Toolchains::DumpToolchains()
Json::Value Toolchains::DumpToolchain(std::string const& lang)
{
+ static const std::vector<ToolchainVariable> CompilerVariables{
+ { "path", "COMPILER", false },
+ { "id", "COMPILER_ID", false },
+ { "version", "COMPILER_VERSION", false },
+ { "target", "COMPILER_TARGET", false },
+ };
+
+ static const std::vector<ToolchainVariable> CompilerImplicitVariables{
+ { "includeDirectories", "IMPLICIT_INCLUDE_DIRECTORIES", true },
+ { "linkDirectories", "IMPLICIT_LINK_DIRECTORIES", true },
+ { "linkFrameworkDirectories", "IMPLICIT_LINK_FRAMEWORK_DIRECTORIES",
+ true },
+ { "linkLibraries", "IMPLICIT_LINK_LIBRARIES", true },
+ };
+
+ static const ToolchainVariable SourceFileExtensionsVariable{
+ "sourceFileExtensions", "SOURCE_FILE_EXTENSIONS", true
+ };
+
const auto& mf =
this->FileAPI.GetCMakeInstance()->GetGlobalGenerator()->GetMakefiles()[0];
Json::Value toolchain = Json::objectValue;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 421e136..45e3b64 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -8102,6 +8102,26 @@ cmLinkItem cmGeneratorTarget::ResolveLinkItem(BT<std::string> const& name,
return cmLinkItem(resolved.Target, false, bt);
}
+bool cmGeneratorTarget::HasPackageReferences() const
+{
+ return this->IsInBuildSystem() &&
+ !this->GetProperty("VS_PACKAGE_REFERENCES")->empty();
+}
+
+std::vector<std::string> cmGeneratorTarget::GetPackageReferences() const
+{
+ std::vector<std::string> packageReferences;
+
+ if (this->IsInBuildSystem()) {
+ if (cmValue vsPackageReferences =
+ this->GetProperty("VS_PACKAGE_REFERENCES")) {
+ cmExpandList(*vsPackageReferences, packageReferences);
+ }
+ }
+
+ return packageReferences;
+}
+
std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
{
if (OutputInfo const* info = this->GetOutputInfo(config)) {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 71212c4..a58dc93 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -424,6 +424,9 @@ public:
cmLinkItem ResolveLinkItem(BT<std::string> const& name,
cmLocalGenerator const* lg) const;
+ bool HasPackageReferences() const;
+ std::vector<std::string> GetPackageReferences() const;
+
// Compute the set of languages compiled by the target. This is
// computed every time it is called because the languages can change
// when source file properties are changed and we do not have enough
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index 5503619..776ee40 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -71,12 +71,13 @@ std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalBorlandMakefileGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int /*jobs*/, bool verbose,
+ const std::string& config, int /*jobs*/, bool verbose,
+ const cmBuildOptions& buildOptions,
std::vector<std::string> const& makeOptions)
{
return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
- makeProgram, projectName, projectDir, targetNames, config, fast,
- cmake::NO_BUILD_PARALLEL_LEVEL, verbose, makeOptions);
+ makeProgram, projectName, projectDir, targetNames, config,
+ cmake::NO_BUILD_PARALLEL_LEVEL, verbose, buildOptions, makeOptions);
}
void cmGlobalBorlandMakefileGenerator::PrintBuildCommandAdvice(
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 646dfff..a280b81 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -59,7 +59,8 @@ protected:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6433681..156ecce 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1994,16 +1994,19 @@ int cmGlobalGenerator::TryCompile(int jobs, const std::string& srcdir,
}
std::string config =
mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
+ cmBuildOptions defaultBuildOptions(false, fast, PackageResolveMode::Disable);
+
return this->Build(jobs, srcdir, bindir, projectName, newTarget, output, "",
- config, false, fast, false, this->TryCompileTimeout);
+ config, defaultBuildOptions, false,
+ this->TryCompileTimeout);
}
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalGenerator::GenerateBuildCommand(
const std::string& /*unused*/, const std::string& /*unused*/,
const std::string& /*unused*/, std::vector<std::string> const& /*unused*/,
- const std::string& /*unused*/, bool /*unused*/, int /*unused*/,
- bool /*unused*/, std::vector<std::string> const& /*unused*/)
+ const std::string& /*unused*/, int /*unused*/, bool /*unused*/,
+ const cmBuildOptions& /*unused*/, std::vector<std::string> const& /*unused*/)
{
GeneratedMakeCommand makeCommand;
makeCommand.Add("cmGlobalGenerator::GenerateBuildCommand not implemented");
@@ -2021,7 +2024,7 @@ int cmGlobalGenerator::Build(
int jobs, const std::string& /*unused*/, const std::string& bindir,
const std::string& projectName, const std::vector<std::string>& targets,
std::string& output, const std::string& makeCommandCSTR,
- const std::string& config, bool clean, bool fast, bool verbose,
+ const std::string& config, const cmBuildOptions& buildOptions, bool verbose,
cmDuration timeout, cmSystemTools::OutputOption outputflag,
std::vector<std::string> const& nativeOptions)
{
@@ -2053,9 +2056,9 @@ int cmGlobalGenerator::Build(
std::string outputBuffer;
std::string* outputPtr = &outputBuffer;
- std::vector<GeneratedMakeCommand> makeCommand =
- this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, targets,
- realConfig, fast, jobs, verbose, nativeOptions);
+ std::vector<GeneratedMakeCommand> makeCommand = this->GenerateBuildCommand(
+ makeCommandCSTR, projectName, bindir, targets, realConfig, jobs, verbose,
+ buildOptions, nativeOptions);
// Workaround to convince some commands to produce output.
if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH &&
@@ -2064,10 +2067,11 @@ int cmGlobalGenerator::Build(
}
// should we do a clean first?
- if (clean) {
+ if (buildOptions.Clean) {
std::vector<GeneratedMakeCommand> cleanCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
- { "clean" }, realConfig, fast, jobs, verbose);
+ { "clean" }, realConfig, jobs, verbose,
+ buildOptions);
output += "\nRun Clean Command:";
output += cleanCommand.front().Printable();
output += "\n";
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 2406798..a43d4a6 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -20,6 +20,7 @@
#include "cm_codecvt.hxx"
+#include "cmBuildOptions.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmExportSet.h"
@@ -229,8 +230,8 @@ public:
int jobs, const std::string& srcdir, const std::string& bindir,
const std::string& projectName,
std::vector<std::string> const& targetNames, std::string& output,
- const std::string& makeProgram, const std::string& config, bool clean,
- bool fast, bool verbose, cmDuration timeout,
+ const std::string& makeProgram, const std::string& config,
+ const cmBuildOptions& buildOptions, bool verbose, cmDuration timeout,
cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_NONE,
std::vector<std::string> const& nativeOptions =
std::vector<std::string>());
@@ -248,7 +249,8 @@ public:
virtual std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions = std::vector<std::string>());
virtual void PrintBuildCommandAdvice(std::ostream& os, int jobs) const;
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index bf537b7..5e51dd2 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -510,7 +510,8 @@ std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalGhsMultiGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& /*config*/, bool /*fast*/, int jobs, bool /*verbose*/,
+ const std::string& /*config*/, int jobs, bool /*verbose*/,
+ const cmBuildOptions& /*buildOptions*/,
std::vector<std::string> const& makeOptions)
{
GeneratedMakeCommand makeCommand = {};
diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h
index 9076e0e..26ea3c7 100644
--- a/Source/cmGlobalGhsMultiGenerator.h
+++ b/Source/cmGlobalGhsMultiGenerator.h
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "cmBuildOptions.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
#include "cmTargetDepend.h"
@@ -87,7 +88,8 @@ protected:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx
index 1b406a6..1a625cc 100644
--- a/Source/cmGlobalJOMMakefileGenerator.cxx
+++ b/Source/cmGlobalJOMMakefileGenerator.cxx
@@ -63,7 +63,8 @@ std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalJOMMakefileGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions,
std::vector<std::string> const& makeOptions)
{
std::vector<std::string> jomMakeOptions;
@@ -81,6 +82,6 @@ cmGlobalJOMMakefileGenerator::GenerateBuildCommand(
}
return cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
- makeProgram, projectName, projectDir, targetNames, config, fast, jobs,
- verbose, jomMakeOptions);
+ makeProgram, projectName, projectDir, targetNames, config, jobs, verbose,
+ buildOptions, jomMakeOptions);
}
diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h
index 8229745..332d1cf 100644
--- a/Source/cmGlobalJOMMakefileGenerator.h
+++ b/Source/cmGlobalJOMMakefileGenerator.h
@@ -52,7 +52,8 @@ protected:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index 9f3d30e..55748cf 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -106,7 +106,8 @@ std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalNMakeMakefileGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int /*jobs*/, bool verbose,
+ const std::string& config, int /*jobs*/, bool verbose,
+ const cmBuildOptions& buildOptions,
std::vector<std::string> const& makeOptions)
{
std::vector<std::string> nmakeMakeOptions;
@@ -117,8 +118,8 @@ cmGlobalNMakeMakefileGenerator::GenerateBuildCommand(
cm::append(nmakeMakeOptions, makeOptions);
return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
- makeProgram, projectName, projectDir, targetNames, config, fast,
- cmake::NO_BUILD_PARALLEL_LEVEL, verbose, nmakeMakeOptions);
+ makeProgram, projectName, projectDir, targetNames, config,
+ cmake::NO_BUILD_PARALLEL_LEVEL, verbose, buildOptions, nmakeMakeOptions);
}
void cmGlobalNMakeMakefileGenerator::PrintBuildCommandAdvice(std::ostream& os,
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index ca5b8d6..b3574eb 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -58,7 +58,8 @@ protected:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 19c4ee3..5b85179 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -955,7 +955,7 @@ cmGlobalNinjaGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& /*projectName*/,
const std::string& /*projectDir*/,
std::vector<std::string> const& targetNames, const std::string& config,
- bool /*fast*/, int jobs, bool verbose,
+ int jobs, bool verbose, const cmBuildOptions& /*buildOptions*/,
std::vector<std::string> const& makeOptions)
{
GeneratedMakeCommand makeCommand;
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 84fc06c..c619b2e 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -18,6 +18,7 @@
#include "cm_codecvt.hxx"
+#include "cmBuildOptions.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalCommonGenerator.h"
#include "cmGlobalGeneratorFactory.h"
@@ -199,7 +200,8 @@ public:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 0556540..ab9ca50 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -518,7 +518,7 @@ cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
const std::string& makeProgram, const std::string& /*projectName*/,
const std::string& /*projectDir*/,
std::vector<std::string> const& targetNames, const std::string& /*config*/,
- bool fast, int jobs, bool verbose,
+ int jobs, bool verbose, const cmBuildOptions& buildOptions,
std::vector<std::string> const& makeOptions)
{
GeneratedMakeCommand makeCommand;
@@ -548,7 +548,7 @@ cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
makeCommand.Add(makeOptions.begin(), makeOptions.end());
for (auto tname : targetNames) {
if (!tname.empty()) {
- if (fast) {
+ if (buildOptions.Fast) {
tname += "/fast";
}
cmSystemTools::ConvertToOutputSlashes(tname);
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 94ee476..5157826 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -12,6 +12,7 @@
#include <string>
#include <vector>
+#include "cmBuildOptions.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalCommonGenerator.h"
#include "cmGlobalGeneratorFactory.h"
@@ -163,7 +164,8 @@ public:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index d7bc05d..e9824fb 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -724,6 +724,10 @@ void cmGlobalVisualStudio10Generator::Generate()
/* clang-format on */
lg->IssueMessage(MessageType::WARNING, e.str());
}
+ if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue(
+ "CMAKE_VS_NUGET_PACKAGE_RESTORE")) {
+ this->CMakeInstance->MarkCliAsUsed("CMAKE_VS_NUGET_PACKAGE_RESTORE");
+ }
}
void cmGlobalVisualStudio10Generator::EnableLanguage(
@@ -1099,7 +1103,8 @@ std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalVisualStudio10Generator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions,
std::vector<std::string> const& makeOptions)
{
std::vector<GeneratedMakeCommand> makeCommands;
@@ -1145,8 +1150,8 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
if (useDevEnv) {
// Use devenv to build solutions containing Intel Fortran projects.
return cmGlobalVisualStudio7Generator::GenerateBuildCommand(
- makeProgram, projectName, projectDir, targetNames, config, fast, jobs,
- verbose, makeOptions);
+ makeProgram, projectName, projectDir, targetNames, config, jobs, verbose,
+ buildOptions, makeOptions);
}
std::vector<std::string> realTargetNames = targetNames;
@@ -1178,8 +1183,66 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
cmSystemTools::ConvertToUnixSlashes(targetProject);
}
}
- makeCommand.Add(std::move(targetProject));
+ makeCommand.Add(targetProject);
+
+ // Check if we do need a restore at all (i.e. if there are package
+ // references and restore has not been disabled by a command line option.
+ PackageResolveMode restoreMode = buildOptions.ResolveMode;
+ bool requiresRestore = true;
+
+ if (restoreMode == PackageResolveMode::Disable) {
+ requiresRestore = false;
+ } else if (cmValue cached =
+ this->CMakeInstance->GetState()->GetCacheEntryValue(
+ tname + "_REQUIRES_VS_PACKAGE_RESTORE")) {
+ requiresRestore = cached.IsOn();
+ } else {
+ // There are no package references defined.
+ requiresRestore = false;
+ }
+
+ // If a restore is required, evaluate the restore mode.
+ if (requiresRestore) {
+ if (restoreMode == PackageResolveMode::OnlyResolve) {
+ // Only invoke the restore target on the project.
+ makeCommand.Add("/t:Restore");
+ } else {
+ // Invoke restore target, unless it has been explicitly disabled.
+ bool restorePackages = true;
+
+ if (this->Version < VS15) {
+ // Package restore is only supported starting from Visual Studio
+ // 2017. Package restore must be executed manually using NuGet
+ // shell for older versions.
+ this->CMakeInstance->IssueMessage(
+ MessageType::WARNING,
+ "Restoring package references is only supported for Visual "
+ "Studio 2017 and later. You have to manually restore the "
+ "packages using NuGet before building the project.");
+ restorePackages = false;
+ } else if (restoreMode == PackageResolveMode::FromCacheVariable) {
+ // Decide if a restore is performed, based on a cache variable.
+ if (cmValue cached =
+ this->CMakeInstance->GetState()->GetCacheEntryValue(
+ "CMAKE_VS_NUGET_PACKAGE_RESTORE"))
+ restorePackages = cached.IsOn();
+ }
+
+ if (restorePackages) {
+ if (this->IsMsBuildRestoreSupported()) {
+ makeCommand.Add("/restore");
+ } else {
+ GeneratedMakeCommand restoreCommand;
+ restoreCommand.Add(makeProgramSelected);
+ restoreCommand.Add(targetProject);
+ restoreCommand.Add("/t:Restore");
+ makeCommands.emplace_back(restoreCommand);
+ }
+ }
+ }
+ }
}
+
std::string configArg = "/p:Configuration=";
if (!config.empty()) {
configArg += config;
@@ -1559,6 +1622,18 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const
return LoadFlagTable(std::string(), this->DefaultNasmFlagTableName, "NASM");
}
+bool cmGlobalVisualStudio10Generator::IsMsBuildRestoreSupported() const
+{
+ if (this->Version >= VS16) {
+ return true;
+ }
+
+ static std::string const vsVer15_7_5 = "15.7.27703.2042";
+ cm::optional<std::string> vsVer = this->GetVSInstanceVersion();
+ return (vsVer &&
+ cmSystemTools::VersionCompareGreaterEq(*vsVer, vsVer15_7_5));
+}
+
std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const
{
std::string const& toolset = this->GetPlatformToolsetString();
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index c8fd149..4977a84 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -43,7 +43,8 @@ public:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
@@ -172,6 +173,8 @@ public:
cmIDEFlagTable const* GetMasmFlagTable() const;
cmIDEFlagTable const* GetNasmFlagTable() const;
+ bool IsMsBuildRestoreSupported() const;
+
protected:
cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index c72b109..91012dd 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -212,7 +212,7 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& /*projectDir*/,
std::vector<std::string> const& targetNames, const std::string& config,
- bool /*fast*/, int /*jobs*/, bool /*verbose*/,
+ int /*jobs*/, bool /*verbose*/, const cmBuildOptions& /*buildOptions*/,
std::vector<std::string> const& makeOptions)
{
// Select the caller- or user-preferred make program, else devenv.
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index d1fb804..33f1063 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -69,7 +69,8 @@ public:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 3e2d92d..fb2a8b6 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -65,12 +65,13 @@ std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalWatcomWMakeGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int /*jobs*/, bool verbose,
+ const std::string& config, int /*jobs*/, bool verbose,
+ const cmBuildOptions& buildOptions,
std::vector<std::string> const& makeOptions)
{
return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
- makeProgram, projectName, projectDir, targetNames, config, fast,
- cmake::NO_BUILD_PARALLEL_LEVEL, verbose, makeOptions);
+ makeProgram, projectName, projectDir, targetNames, config,
+ cmake::NO_BUILD_PARALLEL_LEVEL, verbose, buildOptions, makeOptions);
}
void cmGlobalWatcomWMakeGenerator::PrintBuildCommandAdvice(std::ostream& os,
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index da39d3f..eb93934 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "cmBuildOptions.h"
#include "cmGlobalGeneratorFactory.h"
#include "cmGlobalUnixMakefileGenerator3.h"
@@ -57,7 +58,8 @@ protected:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index bc2a6f7..203addd 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -478,7 +478,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& /*projectDir*/,
std::vector<std::string> const& targetNames, const std::string& config,
- bool /*fast*/, int jobs, bool /*verbose*/,
+ int jobs, bool /*verbose*/, const cmBuildOptions& /*buildOptions*/,
std::vector<std::string> const& makeOptions)
{
GeneratedMakeCommand makeCommand;
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 5917db3..ff6ffe8 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -80,7 +80,8 @@ public:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& config, bool fast, int jobs, bool verbose,
+ const std::string& config, int jobs, bool verbose,
+ const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx
index c027e29..785f356 100644
--- a/Source/cmStandardLevelResolver.cxx
+++ b/Source/cmStandardLevelResolver.cxx
@@ -210,8 +210,9 @@ struct StandardLevelComputer
// If the standard requested is older than the compiler's default or the
// extension mode doesn't match then we need to use a flag.
- if (stdIt < defaultStdIt ||
- (cmp0128 == cmPolicies::NEW && ext != defaultExt)) {
+ if ((cmp0128 != cmPolicies::NEW && stdIt <= defaultStdIt) ||
+ (cmp0128 == cmPolicies::NEW &&
+ (stdIt < defaultStdIt || ext != defaultExt))) {
auto offset = std::distance(cm::cbegin(stds), stdIt);
return cmStrCat("CMAKE_", this->Language, stdsStrings[offset], "_", type,
"_COMPILE_OPTION");
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 96dcf0b..89011a2 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -431,6 +431,9 @@ void cmVisualStudio10TargetGenerator::Generate()
// The groups are stored in a separate file for VS 10
this->WriteGroups();
+
+ // Update cache with project-specific entries.
+ this->UpdateCache();
}
void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
@@ -1000,11 +1003,9 @@ bool cmVisualStudio10TargetGenerator::HasCustomCommands() const
void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0)
{
- std::vector<std::string> packageReferences;
- if (cmValue vsPackageReferences =
- this->GeneratorTarget->GetProperty("VS_PACKAGE_REFERENCES")) {
- cmExpandList(*vsPackageReferences, packageReferences);
- }
+ std::vector<std::string> packageReferences =
+ this->GeneratorTarget->GetPackageReferences();
+
if (!packageReferences.empty()) {
Elem e1(e0, "ItemGroup");
for (std::string const& ri : packageReferences) {
@@ -5375,3 +5376,32 @@ void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1)
e1.Element("StdOutEncoding", "UTF-8");
}
}
+
+void cmVisualStudio10TargetGenerator::UpdateCache()
+{
+ std::vector<std::string> packageReferences;
+
+ if (this->GeneratorTarget->HasPackageReferences()) {
+ // Store a cache entry that later determines, if a package restore is
+ // required.
+ this->GeneratorTarget->Makefile->AddCacheDefinition(
+ this->GeneratorTarget->GetName() + "_REQUIRES_VS_PACKAGE_RESTORE", "ON",
+ "Value Computed by CMake", cmStateEnums::STATIC);
+ } else {
+ // If there are any dependencies that require package restore, inherit the
+ // cache variable.
+ cmGlobalGenerator::TargetDependSet const& unordered =
+ this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
+ using OrderedTargetDependSet =
+ cmGlobalVisualStudioGenerator::OrderedTargetDependSet;
+ OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+
+ for (cmGeneratorTarget const* dt : depends) {
+ if (dt->HasPackageReferences()) {
+ this->GeneratorTarget->Makefile->AddCacheDefinition(
+ this->GeneratorTarget->GetName() + "_REQUIRES_VS_PACKAGE_RESTORE",
+ "ON", "Value Computed by CMake", cmStateEnums::STATIC);
+ }
+ }
+ }
+}
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 79aa5e8..8d777a3 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -198,6 +198,7 @@ private:
std::string GetCSharpSourceLink(cmSourceFile const* source);
void WriteStdOutEncodingUtf8(Elem& e1);
+ void UpdateCache();
private:
friend class cmVS10GeneratorOptions;
diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c
index 62e7e8c..b046aef 100644
--- a/Source/cm_utf8.c
+++ b/Source/cm_utf8.c
@@ -42,6 +42,11 @@ static unsigned int const cm_utf8_min[7] = {
const char* cm_utf8_decode_character(const char* first, const char* last,
unsigned int* pc)
{
+ /* We need at least one byte. */
+ if (first == last) {
+ return 0;
+ }
+
/* Count leading ones in the first byte. */
unsigned char c = (unsigned char)*first++;
unsigned char const ones = cm_utf8_ones[c];
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 72b26e1..ef4e37b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -28,6 +28,7 @@
#include "cm_sys_stat.h"
+#include "cmBuildOptions.h"
#include "cmCMakePath.h"
#include "cmCMakePresetsGraph.h"
#include "cmCommandLineArgument.h"
@@ -3244,8 +3245,8 @@ std::vector<std::string> cmake::GetDebugConfigs()
int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
std::string config, std::vector<std::string> nativeOptions,
- bool clean, bool verbose, const std::string& presetName,
- bool listPresets)
+ cmBuildOptions& buildOptions, bool verbose,
+ const std::string& presetName, bool listPresets)
{
this->SetHomeDirectory("");
this->SetHomeOutputDirectory("");
@@ -3351,8 +3352,12 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
config = expandedPreset->Configuration;
}
- if (!clean && expandedPreset->CleanFirst) {
- clean = *expandedPreset->CleanFirst;
+ if (!buildOptions.Clean && expandedPreset->CleanFirst) {
+ buildOptions.Clean = *expandedPreset->CleanFirst;
+ }
+
+ if (expandedPreset->ResolvePackageReferences) {
+ buildOptions.ResolveMode = *expandedPreset->ResolvePackageReferences;
}
if (!verbose && expandedPreset->Verbose) {
@@ -3491,7 +3496,7 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
this->GlobalGenerator->PrintBuildCommandAdvice(std::cerr, jobs);
return this->GlobalGenerator->Build(
- jobs, "", dir, projName, targets, output, "", config, clean, false,
+ jobs, "", dir, projName, targets, output, "", config, buildOptions,
verbose, cmDuration::zero(), cmSystemTools::OUTPUT_PASSTHROUGH,
nativeOptions);
}
diff --git a/Source/cmake.h b/Source/cmake.h
index aee9c04..1187be5 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -45,6 +45,7 @@ class cmMakefileProfilingData;
#endif
class cmMessenger;
class cmVariableWatch;
+struct cmBuildOptions;
struct cmDocumentationEntry;
/** \brief Represents a cmake invocation.
@@ -587,8 +588,8 @@ public:
//! run the --build option
int Build(int jobs, std::string dir, std::vector<std::string> targets,
std::string config, std::vector<std::string> nativeOptions,
- bool clean, bool verbose, const std::string& presetName,
- bool listPresets);
+ cmBuildOptions& buildOptions, bool verbose,
+ const std::string& presetName, bool listPresets);
//! run the --open option
bool Open(const std::string& dir, bool dryRun);
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 00aafdc..22fdcf8 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -5,6 +5,7 @@
#include <algorithm>
#include <cassert>
+#include <cctype>
#include <climits>
#include <cstdio>
#include <cstring>
@@ -19,6 +20,7 @@
#include <cm3p/uv.h>
+#include "cmBuildOptions.h"
#include "cmCommandLineArgument.h"
#include "cmConsoleBuf.h"
#include "cmDocumentationEntry.h" // IWYU pragma: keep
@@ -445,6 +447,7 @@ int do_build(int ac, char const* const* av)
bool cleanFirst = false;
bool foundClean = false;
bool foundNonClean = false;
+ PackageResolveMode resolveMode = PackageResolveMode::FromCacheVariable;
bool verbose = cmSystemTools::HasEnv("VERBOSE");
std::string presetName;
bool listPresets = false;
@@ -478,6 +481,22 @@ int do_build(int ac, char const* const* av)
}
return false;
};
+ auto resolvePackagesLambda = [&](std::string const& value) -> bool {
+ std::string v = value;
+ std::transform(v.begin(), v.end(), v.begin(), ::tolower);
+
+ if (v == "on") {
+ resolveMode = PackageResolveMode::Force;
+ } else if (v == "only") {
+ resolveMode = PackageResolveMode::OnlyResolve;
+ } else if (v == "off") {
+ resolveMode = PackageResolveMode::Disable;
+ } else {
+ return false;
+ }
+
+ return true;
+ };
auto verboseLambda = [&](std::string const&) -> bool {
verbose = true;
return true;
@@ -514,6 +533,8 @@ int do_build(int ac, char const* const* av)
cleanFirst = true;
return true;
} },
+ CommandArgument{ "--resolve-package-references",
+ CommandArgument::Values::One, resolvePackagesLambda },
CommandArgument{ "-v", CommandArgument::Values::Zero, verboseLambda },
CommandArgument{ "--verbose", CommandArgument::Values::Zero,
verboseLambda },
@@ -639,6 +660,8 @@ int do_build(int ac, char const* const* av)
" --config <cfg> = For multi-configuration tools, choose <cfg>.\n"
" --clean-first = Build target 'clean' first, then build.\n"
" (To clean only, use --target 'clean'.)\n"
+ " --resolve-package-references={on|only|off}\n"
+ " = Restore/resolve package references during build.\n"
" --verbose, -v = Enable verbose output - if supported - including\n"
" the build commands to be executed. \n"
" -- = Pass remaining options to the native tool.\n"
@@ -656,8 +679,10 @@ int do_build(int ac, char const* const* av)
cmakemainProgressCallback(msg, prog, &cm);
});
+ cmBuildOptions buildOptions(cleanFirst, false, resolveMode);
+
return cm.Build(jobs, std::move(dir), std::move(targets), std::move(config),
- std::move(nativeOptions), cleanFirst, verbose, presetName,
+ std::move(nativeOptions), buildOptions, verbose, presetName,
listPresets);
#endif
}
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 7da5971..2253a83 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -192,6 +192,7 @@ endif()
if(KWSYS_USE_Directory)
set(KWSYS_USE_Encoding 1)
set(KWSYS_USE_Status 1)
+ set(KWSYS_USE_SystemTools 1)
endif()
if(KWSYS_USE_DynamicLoader)
set(KWSYS_USE_Encoding 1)
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index 6e31cbf..d520c14 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -7,6 +7,8 @@
#include KWSYS_HEADER(Encoding.hxx)
+#include KWSYS_HEADER(SystemTools.hxx)
+
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
@@ -16,15 +18,48 @@
#endif
#include <string>
+#include <utility>
#include <vector>
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
+
+# include <ctype.h>
+# include <fcntl.h>
+# include <io.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+#endif
+
namespace KWSYS_NAMESPACE {
class DirectoryInternals
{
public:
+ struct FileData
+ {
+ std::string Name;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ _wfinddata_t FindData;
+#endif
+ FileData(std::string name
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ ,
+ _wfinddata_t data
+#endif
+ )
+ : Name(std::move(name))
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ , FindData(std::move(data))
+#endif
+ {
+ }
+ };
// Array of Files
- std::vector<std::string> Files;
+ std::vector<FileData> Files;
// Path to Open'ed directory
std::string Path;
@@ -59,10 +94,45 @@ unsigned long Directory::GetNumberOfFiles() const
const char* Directory::GetFile(unsigned long dindex) const
{
- if (dindex >= this->Internal->Files.size()) {
- return nullptr;
+ return this->Internal->Files[dindex].Name.c_str();
+}
+
+std::string const& Directory::GetFileName(std::size_t i) const
+{
+ return this->Internal->Files[i].Name;
+}
+
+std::string Directory::GetFilePath(std::size_t i) const
+{
+ std::string abs = this->Internal->Path;
+ if (!abs.empty() && abs.back() != '/') {
+ abs += '/';
}
- return this->Internal->Files[dindex].c_str();
+ abs += this->Internal->Files[i].Name;
+ return abs;
+}
+
+bool Directory::FileIsDirectory(std::size_t i) const
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ _wfinddata_t const& data = this->Internal->Files[i].FindData;
+ return (data.attrib & FILE_ATTRIBUTE_DIRECTORY) != 0;
+#else
+ std::string const& path = this->GetFilePath(i);
+ return kwsys::SystemTools::FileIsDirectory(path);
+#endif
+}
+
+bool Directory::FileIsSymlink(std::size_t i) const
+{
+ std::string const& path = this->GetFilePath(i);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ _wfinddata_t const& data = this->Internal->Files[i].FindData;
+ return kwsys::SystemTools::FileIsSymlinkWithAttr(
+ Encoding::ToWindowsExtendedPath(path), data.attrib);
+#else
+ return kwsys::SystemTools::FileIsSymlink(path);
+#endif
}
const char* Directory::GetPath() const
@@ -81,16 +151,6 @@ void Directory::Clear()
// First Windows platforms
#if defined(_WIN32) && !defined(__CYGWIN__)
-# include <windows.h>
-
-# include <ctype.h>
-# include <fcntl.h>
-# include <io.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-# include <sys/stat.h>
-# include <sys/types.h>
namespace KWSYS_NAMESPACE {
@@ -133,7 +193,7 @@ Status Directory::Load(std::string const& name, std::string* errorMessage)
// Loop through names
do {
- this->Internal->Files.push_back(Encoding::ToNarrow(data.name));
+ this->Internal->Files.emplace_back(Encoding::ToNarrow(data.name), data);
} while (_wfindnext(srchHandle, &data) != -1);
this->Internal->Path = name;
if (_findclose(srchHandle) == -1) {
diff --git a/Source/kwsys/Directory.hxx.in b/Source/kwsys/Directory.hxx.in
index d501116..9d0f462 100644
--- a/Source/kwsys/Directory.hxx.in
+++ b/Source/kwsys/Directory.hxx.in
@@ -6,6 +6,7 @@
#include <@KWSYS_NAMESPACE@/Configure.h>
#include <@KWSYS_NAMESPACE@/Status.hxx>
+#include <cstddef>
#include <string>
namespace @KWSYS_NAMESPACE@ {
@@ -55,6 +56,26 @@ public:
const char* GetFile(unsigned long) const;
/**
+ * Return the name of the file at the given 0-based index.
+ */
+ std::string const& GetFileName(std::size_t i) const;
+
+ /**
+ * Return the absolute path to the file at the given 0-based index.
+ */
+ std::string GetFilePath(std::size_t i) const;
+
+ /**
+ * Return whether the file at the given 0-based index is a directory.
+ */
+ bool FileIsDirectory(std::size_t i) const;
+
+ /**
+ * Return whether the file at the given 0-based index is a symlink.
+ */
+ bool FileIsSymlink(std::size_t i) const;
+
+ /**
* Return the path to Open'ed directory
*/
const char* GetPath() const;
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index c6d4b19..fa2c295 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -213,8 +213,8 @@ bool Glob::RecurseDirectory(std::string::size_type start,
fname = kwsys::SystemTools::LowerCase(fname);
#endif
- bool isDir = kwsys::SystemTools::FileIsDirectory(realname);
- bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname);
+ bool isDir = d.FileIsDirectory(cc);
+ bool isSymLink = d.FileIsSymlink(cc);
if (isDir && (!isSymLink || this->RecurseThroughSymlinks)) {
if (isSymLink) {
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index c339fd5..c38b456 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2287,7 +2287,7 @@ bool SystemTools::FilesDiffer(const std::string& source,
if (statSource.nFileSizeHigh == 0 && statSource.nFileSizeLow == 0) {
return false;
}
- off_t nleft =
+ auto nleft =
((__int64)statSource.nFileSizeHigh << 32) + statSource.nFileSizeLow;
#else
@@ -3085,11 +3085,10 @@ bool SystemTools::FileIsExecutable(const std::string& name)
return !FileIsDirectory(name) && TestFileAccess(name, TEST_FILE_EXECUTE);
}
-bool SystemTools::FileIsSymlink(const std::string& name)
-{
#if defined(_WIN32)
- std::wstring path = Encoding::ToWindowsExtendedPath(name);
- DWORD attr = GetFileAttributesW(path.c_str());
+bool SystemTools::FileIsSymlinkWithAttr(const std::wstring& path,
+ unsigned long attr)
+{
if (attr != INVALID_FILE_ATTRIBUTES) {
if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
// FILE_ATTRIBUTE_REPARSE_POINT means:
@@ -3118,9 +3117,17 @@ bool SystemTools::FileIsSymlink(const std::string& name)
(reparseTag == IO_REPARSE_TAG_MOUNT_POINT);
}
return false;
- } else {
- return false;
}
+
+ return false;
+}
+#endif
+
+bool SystemTools::FileIsSymlink(const std::string& name)
+{
+#if defined(_WIN32)
+ std::wstring path = Encoding::ToWindowsExtendedPath(name);
+ return FileIsSymlinkWithAttr(path, GetFileAttributesW(path.c_str()));
#else
struct stat fs;
if (lstat(name.c_str(), &fs) == 0) {
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 6684695..acce015 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -688,6 +688,16 @@ public:
*/
static bool FileIsExecutable(const std::string& name);
+#if defined(_WIN32)
+ /**
+ * Return true if the file with FileAttributes `attr` is a symlink
+ * Only available on Windows. This avoids an expensive `GetFileAttributesW`
+ * call.
+ */
+ static bool FileIsSymlinkWithAttr(const std::wstring& path,
+ unsigned long attr);
+#endif
+
/**
* Return true if the file is a symlink
*/
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index dd786b8..6bea788 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -619,6 +619,7 @@ endif()
if(CMAKE_GENERATOR MATCHES "^Visual Studio (1[6-9]|[2-9][0-9])")
add_RunCMake_test(VsDotnetSdk)
+ add_RunCMake_test(VsNugetPackageRestore)
endif()
if(XCODE_VERSION)
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good.json.in b/Tests/RunCMake/CMakePresetsBuild/Good.json.in
index c7f318c..568907c 100644
--- a/Tests/RunCMake/CMakePresetsBuild/Good.json.in
+++ b/Tests/RunCMake/CMakePresetsBuild/Good.json.in
@@ -1,5 +1,5 @@
{
- "version": 2,
+ "version": 4,
"configurePresets": [
{
"name": "default",
@@ -78,6 +78,12 @@
"name": "singleTarget",
"inherits": "build-default",
"targets": "good"
+ },
+ {
+ "name": "initResolve",
+ "inherits": "build-default",
+ "targets": "good",
+ "resolvePackageReferences": "off"
}
]
}
diff --git a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake
index b37c770..2fe0407 100644
--- a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake
@@ -70,7 +70,7 @@ else()
set(Good_json_jobs [["jobs": 0,]])
endif()
-run_cmake_build_presets(Good "default;other" "build-other;withEnvironment;noEnvironment;macros;vendorObject;singleTarget")
+run_cmake_build_presets(Good "default;other" "build-other;withEnvironment;noEnvironment;macros;vendorObject;singleTarget;initResolve")
run_cmake_build_presets(InvalidConfigurePreset "default" "badConfigurePreset")
run_cmake_build_presets(Condition "default" "enabled;disabled")
diff --git a/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt
new file mode 100644
index 0000000..4811bea
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt
@@ -0,0 +1 @@
+^Usage: cmake --build <dir> +\[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake
index 99bb3f0..b309d74 100644
--- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake
+++ b/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake
@@ -4,5 +4,4 @@ enable_language(@lang@)
string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}")
string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}")
-set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@)
add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@")
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake
index 4e85397..4e85397 100644
--- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake
+++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake
new file mode 100644
index 0000000..5b7358a
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@)
+set(CMAKE_@lang@_STANDARD @standard_default@)
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake
index abe293c..abe293c 100644
--- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake
+++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake
new file mode 100644
index 0000000..6923c11
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake
@@ -0,0 +1 @@
+set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@)
diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake
index 4f767fa..4f767fa 100644
--- a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake
+++ b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake
new file mode 100644
index 0000000..73c0641
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_@lang@_EXTENSIONS @extensions_default@)
+set(CMAKE_@lang@_STANDARD @standard_default@)
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake
new file mode 100644
index 0000000..8074b9d
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake
@@ -0,0 +1,12 @@
+foreach(flag @flags@)
+ string(FIND "${actual_stdout}" "${flag}" position)
+
+ if(NOT position EQUAL -1)
+ set(found TRUE)
+ break()
+ endif()
+endforeach()
+
+if(NOT found)
+ set(RunCMake_TEST_FAILED "No compile flags from \"@flags@\" found for LANG_STANDARD=default.")
+endif()
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake
new file mode 100644
index 0000000..3be0f10
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake
@@ -0,0 +1 @@
+set(CMAKE_@lang@_STANDARD @standard_default@)
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake
index 0a5606a..7974093 100644
--- a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake
+++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake
@@ -1,7 +1,5 @@
-enable_language(@lang@)
cmake_policy(SET CMP0128 OLD)
set(CMAKE_POLICY_WARNING_CMP0128 ON)
set(CMAKE_@lang@_EXTENSIONS @extensions_default@)
set(CMAKE_@lang@_STANDARD @standard_default@)
-add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@")
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake
index cd7af2c..33425a1 100644
--- a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake
+++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake
@@ -1,6 +1,4 @@
-enable_language(@lang@)
cmake_policy(SET CMP0128 OLD)
set(CMAKE_POLICY_WARNING_CMP0128 ON)
set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@)
-add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@")
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake
deleted file mode 100644
index 32578d1..0000000
--- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-enable_language(@lang@)
-
-# Make sure the compile command is not hidden.
-string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}")
-string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}")
-
-set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@)
-set(CMAKE_@lang@_STANDARD @standard_default@)
-add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@")
diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake
deleted file mode 100644
index 8ef3a72..0000000
--- a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-enable_language(@lang@)
-
-# Make sure the compile command is not hidden.
-string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}")
-string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}")
-
-set(CMAKE_@lang@_EXTENSIONS @extensions_default@)
-set(CMAKE_@lang@_STANDARD @standard_default@)
-add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@")
diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
index ebd981b..ad9619e 100644
--- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
@@ -35,11 +35,13 @@ elseif (cxx_std_98 IN_LIST CXX_FEATURES AND cxx_std_11 IN_LIST CXX_FEATURES)
endif()
configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/CMakeLists.txt" COPYONLY)
+file(READ "${RunCMake_SOURCE_DIR}/CMP0128Common.cmake" cmp0128_common)
function(test_build)
set(test ${name}-${lang})
- configure_file("${RunCMake_SOURCE_DIR}/${name}.cmake" "${RunCMake_BINARY_DIR}/${test}.cmake" @ONLY)
+ file(READ "${RunCMake_SOURCE_DIR}/${name}.cmake" cmake)
+ file(CONFIGURE OUTPUT "${RunCMake_BINARY_DIR}/${test}.cmake" CONTENT "${cmake}${cmp0128_common}" @ONLY)
if(EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-check.cmake")
configure_file("${RunCMake_SOURCE_DIR}/${name}-build-check.cmake" "${RunCMake_BINARY_DIR}/${test}-build-check.cmake" @ONLY)
endif()
@@ -68,7 +70,24 @@ macro(mangle_flags variable)
list(APPEND flags "${result}")
endmacro()
-function(test_extensions_opposite)
+function(test_cmp0128_old_same_standard)
+ if(extensions_default)
+ set(flag_ext "_EXT")
+ endif()
+
+ set(flag "${${lang}${${lang}_STANDARD_DEFAULT}${flag_ext}_FLAG}")
+
+ if(NOT flag)
+ return()
+ endif()
+
+ mangle_flags(flag)
+
+ set(name CMP0128OldSameStandard)
+ test_build(--verbose)
+endfunction()
+
+function(test_cmp0128_new_extensions_opposite)
if(extensions_opposite)
set(flag_ext "_EXT")
endif()
@@ -83,16 +102,16 @@ function(test_extensions_opposite)
# Make sure we enable/disable extensions when:
# 1. LANG_STANDARD is unset.
- set(name ExtensionsStandardUnset)
+ set(name CMP0128NewExtensionsStandardUnset)
set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW)
test_build(--verbose)
# 2. LANG_STANDARD matches CMAKE_LANG_STANDARD_DEFAULT.
- set(name ExtensionsStandardDefault)
+ set(name CMP0128NewExtensionsStandardDefault)
test_build(--verbose)
endfunction()
-function(test_no_unnecessary_flag)
+function(test_cmp0128_new_no_unnecessary_flag)
set(standard_flag "${${lang}${${lang}_STANDARD_DEFAULT}_FLAG}")
set(extension_flag "${${lang}${${lang}_STANDARD_DEFAULT}_EXT_FLAG}")
@@ -103,7 +122,7 @@ function(test_no_unnecessary_flag)
mangle_flags(standard_flag)
mangle_flags(extension_flag)
- set(name NoUnnecessaryFlag)
+ set(name CMP0128NewNoUnnecessaryFlag)
set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW)
test_build(--verbose)
endfunction()
@@ -144,8 +163,9 @@ function(test_lang lang ext)
set(extensions_opposite ON)
endif()
- test_extensions_opposite()
- test_no_unnecessary_flag()
+ test_cmp0128_new_extensions_opposite()
+ test_cmp0128_new_no_unnecessary_flag()
+ test_cmp0128_old_same_standard()
test_cmp0128_warn_match()
test_cmp0128_warn_unset()
endfunction()
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
index a4244e3..48f8b23 100644
--- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
@@ -112,7 +112,7 @@ function(__ep_test_with_build_with_server testName)
file(READ ${URL_FILE} SERVER_URL)
message(STATUS "URL : ${URL_FILE} - ${SERVER_URL}")
- run_cmake_with_options(${testName} ${CMAKE_COMMAND} -DSERVER_URL=${SERVER_URL} )
+ run_cmake_with_options(${testName} -DSERVER_URL=${SERVER_URL})
run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean)
run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
endfunction()
diff --git a/Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt b/Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt
new file mode 100644
index 0000000..d8200fc
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt b/Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt
new file mode 100644
index 0000000..56920d9
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.12)
+
+project(NuGetTestProject VERSION 1.0.0 LANGUAGES CSharp)
+
+add_library(NuGetPackage SHARED "Library.cs")
+set_target_properties(NuGetPackage PROPERTIES
+ VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.7.2"
+ VS_DOTNET_REFERENCES "System")
+install(TARGETS NuGetPackage)
+
+set(CPACK_GENERATOR "NuGet")
+set(CPACK_PACKAGE_NAME "NuGetTestProject")
+set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
+set(CPACK_PACKAGE_DESCRIPTION "Package to test automatic NuGet package restore.")
+set(CPACK_PACKAGE_VENDOR "CMake.org")
+
+include(CPack)
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs b/Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs
new file mode 100644
index 0000000..d9ae85a
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace CMake
+{
+ public class NuGetTest
+ {
+ public static int GetNumber() => 42;
+ }
+}
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Program.cs b/Tests/RunCMake/VsNugetPackageRestore/Program.cs
new file mode 100644
index 0000000..681461f
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Program.cs
@@ -0,0 +1,14 @@
+using System;
+using CMake;
+
+namespace Test
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ Console.WriteLine(NuGetTest.GetNumber());
+ Console.ReadKey();
+ }
+ }
+}
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata
new file mode 100644
index 0000000..6a87d0a
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata
@@ -0,0 +1,5 @@
+{
+ "version": 2,
+ "contentHash": "2sG1Ws4da8r6qj7rUAZ1GaOjkELonH0X+vR9yfDwgg+QxG0cpRIfGqEXKAkGT+UCwU24ogJcm8IA9dXv5zmLXg==",
+ "source": null
+}
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg
new file mode 100644
index 0000000..5569a29
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg
Binary files differ
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha512 b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha512
new file mode 100644
index 0000000..5526b76
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha512
@@ -0,0 +1 @@
+2sG1Ws4da8r6qj7rUAZ1GaOjkELonH0X+vR9yfDwgg+QxG0cpRIfGqEXKAkGT+UCwU24ogJcm8IA9dXv5zmLXg==
diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec
new file mode 100644
index 0000000..9a943a8
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <id>NuGetTestProject</id>
+ <version>1.0.0</version>
+ <authors>CMake.org</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>Package to test automatic NuGet package restore.</description>
+ <summary>NuGetTestProject built using CMake</summary>
+ </metadata>
+</package>
diff --git a/Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake b/Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake
new file mode 100644
index 0000000..625167c
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake
@@ -0,0 +1,12 @@
+cmake_policy(SET CMP0053 NEW)
+include(RunCMake)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VsNugetPackageRestore)
+run_cmake(VsNugetPackageRestore)
+
+set(RunCMake_TEST_NO_CLEAN 1)
+run_cmake_command(vs-nuget-package-restore-off ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=off)
+run_cmake_command(vs-nuget-package-restore-only ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=only)
+run_cmake_command(vs-nuget-package-restore-on ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=on)
+run_cmake_command(vs-nuget-package-restore-wrong ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=wrong)
+set(RunCMake_TEST_NO_CLEAN 0)
diff --git a/Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake b/Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake
new file mode 100644
index 0000000..a0227df
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake
@@ -0,0 +1,9 @@
+enable_language(CSharp)
+
+add_executable(TestProgram "Program.cs")
+configure_file("nuget.config.in" "nuget.config")
+set_target_properties(TestProgram PROPERTIES
+ VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.7.2"
+ VS_DOTNET_REFERENCES "System"
+ VS_PACKAGE_REFERENCES "NuGetTestProject_1.0.0"
+)
diff --git a/Tests/RunCMake/VsNugetPackageRestore/nuget.config.in b/Tests/RunCMake/VsNugetPackageRestore/nuget.config.in
new file mode 100644
index 0000000..2e54c8f
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/nuget.config.in
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <packageSources>
+ <clear />
+ <add key="local" value="@CMAKE_CURRENT_SOURCE_DIR@/Repository/" />
+ </packageSources>
+</configuration>
diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt
new file mode 100644
index 0000000..4811bea
--- /dev/null
+++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt
@@ -0,0 +1 @@
+^Usage: cmake --build <dir> +\[options\] \[-- \[native-options\]\]