You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(vsvars): Refactor vcvars discovery with reusable function
* Introduced `Vcvars_FindFirstValidMsvcVersion()` to encapsulate logic for
selecting the first valid MSVC version from a prioritized list that provides
a `vcvars` batch script.
* Replaced duplicated logic with a call to the new function, improving clarity
and maintainability.
* Ensured compatibility with both configuration and script modes.
* Added the function to test coverage and documented it with a dedicated
`.. command::` section.
* Improved formatting and consistency in toolset-to-version mapping
documentation, clarifying alias relationships.
Copy file name to clipboardExpand all lines: FindVcvars.cmake
+70-23Lines changed: 70 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -97,6 +97,31 @@ This module also defines the following functions
97
97
The name of the variable to be set with the Visual Studio version.
98
98
99
99
100
+
.. command:: Vcvars_FindFirstValidMsvcVersion
101
+
102
+
The `Vcvars_FindFirstValidMsvcVersion()` function identifies the first MSVC version from a list of candidates that has an associated and discoverable `vcvars` batch script::
Specify the Visual Studio architecture. Possible values are `32` or `64`.
112
+
113
+
``<candidate_msvc_versions>``
114
+
A list of MSVC version numbers to check (e.g., `1949;1948;1947`). The list should be ordered from most to least preferred.
115
+
116
+
``<msvc_version_output_varname>``
117
+
The name of the variable to store the first matching MSVC version.
118
+
119
+
``<batch_file_output_varname>``
120
+
The name of the variable to store the path to the corresponding `vcvars` batch script.
121
+
122
+
This is typically used internally to identify the most recent supported Visual Studio installation that provides the appropriate environment setup scripts, but it can also be reused in custom detection logic when running in configuration or script mode.
123
+
124
+
100
125
The module also defines the following variables mapping MSVC versions
101
126
to their associated toolset or Visual Studio major release:
_vcvars_message(STATUS"Setting ${msvc_version_output_varname} to '${_msvc_version}' as it was the newest Visual Studio installed providing vcvars scripts")
0 commit comments