Commit Graph

85 Commits

Author SHA1 Message Date
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Brad King
d5118ed2e5 Merge branch 'backport-vs-sdk-selection' into vs-sdk-selection 2023-08-10 10:00:53 -04:00
Brad King
89b611ab32 VS: Select latest Windows SDK even when targeting Windows 8.1 and below
The policy added by commit f90c8ab54e (VS: Select latest available
Windows SDK version by default, 2023-04-03, v3.27.0-rc1~206^2~1) applied
only when targeting Windows 10+.  Apply it to older versions too.

Fixes: #25170
Issue: #16202
2023-08-10 09:59:25 -04:00
Brad King
ae97d82e83 VS: Teach CMAKE_GENERATOR_PLATFORM to support Windows 8.1 SDK selection
Honor an explicit `version=8.1` field value regardless of the Windows
target version.

Issue: #25170
2023-08-10 09:57:00 -04:00
Brad King
15ff89654b VS: Teach CMAKE_GENERATOR_PLATFORM to use Windows 10 SDKs for older versions
Honor an explicit `version=` field selecting a Windows 10 SDK regardless
of the Windows target version.

Issue: #25170
2023-08-10 09:34:50 -04:00
Brad King
bba1a23da9 VS: Consolidate Windows SDK major version selection dispatch
Make logic choosing between Windows 10 SDKs and the Windows 8.1 SDK
easier to follow by consolidating it in the VS 14 generator.  The only
information we need from VS 15+ generators is whether the 8.1 SDK is
installed.
2023-08-10 09:33:20 -04:00
Brad King
209973e510 VS: Do not print empty Windows SDK version when none is selected 2023-08-10 09:33:19 -04:00
Ben Boeckel
d4144b9c0a strings: use emplace_back with cmStrCat arguments 2023-07-27 20:15:51 -04:00
Ben Boeckel
809248a0c9 strings: use character literals where possible 2023-07-27 20:00:59 -04:00
Ben Boeckel
7137b17835 cmStrCat: use in Windows-specific sources 2023-07-27 20:00:59 -04:00
Ben Boeckel
a5ba00bdf8 strings: combine string literals where possible 2023-07-27 19:10:39 -04:00
Ben Boeckel
3f1378fbca strings: compare to static string_view instances in Windows-only code 2023-07-27 19:10:39 -04:00
Brad King
8ecb645934 VS: Select Windows SDK matching WindowsSDKVersion env var
In an environment established by `vcvarsall.bat` or similar, this
environment variable may be set to select a Windows SDK version.
If the VS generator is used in such an environment, use that SDK.
This is similar to how `CMAKE_GENERATOR_INSTANCE` defaults using
a `VS##0COMNTOOLS` environment variable.

Fixes: #17992
2023-04-05 12:06:22 -04:00
Brad King
f90c8ab54e VS: Select latest available Windows SDK version by default
Add policy `CMP0149` to stop preferring SDKs exactly matching
`CMAKE_SYSTEM_VERSION` over the latest SDK.

Fixes: #16202
2023-04-05 12:06:22 -04:00
Brad King
b512c53d43 VS: Add support for setting WindowsTargetPlatformVersion to 10.0
VS 2019 and above support this value to select a SDK version
automatically.

Fixes: #21403
2023-04-05 12:06:22 -04:00
Brad King
2f3d945f83 VS: Add CMAKE_GENERATOR_PLATFORM field to control Windows SDK selection
Add a `version=` field to explicitly control the SDK version selection
without relying on `CMAKE_SYSTEM_VERSION`.

Fixes: #16713
2023-04-05 12:06:22 -04:00
Brad King
e259063b0a VS: Defer Windows SDK selection until CMAKE_GENERATOR_PLATFORM is known
Prepare to teach `CMAKE_GENERATOR_PLATFORM` to affect SDK selection.
2023-04-05 12:06:22 -04:00
Brad King
8499374c6a VS: Simplify logic to require SDK for Windows Store
Revise logic added by commit d7e863c1c1 (VS: Do not fail on Windows 10
with VS 2015 if no SDK is available, 2016-01-21, v3.4.3~1^2) to make the
requirement decision locally and simplify signatures.
2023-04-05 12:06:21 -04:00
Ben Boeckel
9e81a9b45c clang-tidy: fix misc-unused-parameters lints 2022-11-29 12:39:45 -05:00
Ben Boeckel
b72c45e39f clang-tidy: fix readability-else-after-return lints 2022-11-29 12:39:29 -05:00
Ben Boeckel
1b929ba8e4 clang-tidy: fix modernize-use-nullptr lints 2022-11-29 12:39:29 -05:00
Alex Turbov
6e3e8827fa Refactor: cmGlobalGeneratorFactory::GetDocumentation returns entry
Before, a documentation entry was in/out parameter.
Now it's a normal return value.

This also makes possible to eliminate defaulted default ctor
for `cmDocumentationEntry` for C++ 11.

Also, simplify `cmake::AppendGlobalGeneratorsDocumentation()`.
2022-11-17 16:37:13 +04:00
Sumit Bhardwaj
a88f98b3be Make cmGlobalVisualStudioGenerator::VSVersion enum class 2022-01-25 11:25:18 -08:00
NAKAMURA Takumi
0e58a5ea07 Source: Fix possible IWYU warnings in Windows generators 2021-11-20 00:50:33 +09:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
jonathan molinatto
1e67482daf VS: Generalize Win10 max SDK version to all VS generators
The `CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` variable added in
CMake 3.19 by commit ba497111f6 (VS: Add option for custom Win10 SDK
version maximum, 2020-08-20, v3.19.0-rc1~262^2) was documented as if it
worked for all generators but implemented only to override CMake's
builtin default for the VS 2015 max SDK version.  Generalize the
variable to set a custom max SDK version for later VS versions too.

Fixes: #21720
2021-01-20 14:46:34 -05:00
Kyle Edwards
5a36542086 Refactor: Add allowArch parameter to cmake::CreateGlobalGenerator() 2020-10-05 09:49:59 -04:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
jonathan molinatto
ba497111f6 VS: Add option for custom Win10 SDK version maximum
Since commit 83ddc4d289 (VS: Do not select a Windows SDK too high for
current VS version, 2017-08-07, v3.13.0-rc1~72^2~2) we enforce a maximum
SDK version for the VS 2015 generator.  The blog post linked in the
original commit is no longer available, but it can be seen here:

* https://web.archive.org/web/20190108032520/https://blogs.msdn.microsoft.com/chuckw/2018/10/02/windows-10-october-2018-update/

In particular, it states:

> VS 2015 Users: The Windows 10 SDK (15063, 16299, 17134, 17763)
> is officially only supported for VS 2017.

However, in some circumstances a higher version can be used.

Add a `CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` to override the
generator's default maximum SDK version.

Fixes: #20633
2020-08-25 15:27:38 -04:00
Kyle Edwards
6051a49c78 Visual Studio: Add Android support 2020-06-24 08:41:09 -04:00
Marc Chevrier
968477517e Refactoring: suppress cmEraseIf in favor of cm::erase_if 2020-01-09 11:19:20 +01:00
Marc Chevrier
a00960288b GlobalGenerator family: modernize memory management 2020-01-07 11:03:11 +01:00
Sebastian Holtermann
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value
argument instead of a `const char *`.

Benefits are:
- `std::string` can be passed to `cmMakefile::AddDefinition` directly without
  the `c_str()` plus string length recomputation fallback.
- Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at
  compile time.

In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid
`std::string::c_str` calls and the `std::string` is passed directly.
Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might
be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
2019-07-24 11:11:25 +02:00
Brad King
fcdd6efb72 Merge topic 'vs-win-sdk'
4dab8e69bd VS: Tell VS 2019 to use Windows SDK 8.1 explicitly when needed
35bf9ded3b VS: Factor out a method to set the Windows SDK version internally

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2989
2019-02-20 08:54:36 -05:00
Brad King
35bf9ded3b VS: Factor out a method to set the Windows SDK version internally 2019-02-19 09:31:50 -05:00
Vitaly Stakhovsky
950c099d83 cmake: Progress functions use std::string param 2019-02-11 10:32:43 -05:00
Brad King
8bba458ea5 Add global generator factory method to get default platform name 2019-01-18 12:30:19 -05:00
Brad King
818df52c48 Add global generator factory method to get list of known platforms
Add a `cmGlobalGeneratorFactory::GetKnownPlatforms` method to return
a list of known possible values for `CMAKE_GENERATOR_PLATFORM`.
Implement the method for each generator by referencing the list of
possible values documented in `Help/generator/*.rst` for it.

Co-Author: Julien Jomier <julien.jomier@kitware.com>
2019-01-18 12:29:53 -05:00
Brad King
8144b00e32 Split global generator factory list with and without platforms
Replace `cmGlobalGeneratorFactory::GetGenerators` with a pair of methods
to split the list of generator names into those that have platforms in
the name and those that do not.
2019-01-18 12:29:53 -05:00
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Brad King
40a732800d VS: Clarify global generator constructor interface
Make the constructors protected since they should be produced through
factories.  Also rename `platform{ => InGenerator}Name` to clarify
the meaning of the argument.
2019-01-10 09:38:35 -05:00
Brad King
163cc8bbdd VS: Convert WriteSLNHeader to non-virtual lookup table 2019-01-10 07:52:51 -05:00
Brad King
99a224e3ee Merge topic 'vs-json-flag-table'
8107508b3e Remove old flag table headers
6d855fbf44 Replace header flag tables with json reading
9c60ae5f11 VS: Add flag table entry for -JMC
584ad067ba VS: Fix flag table entry for -Qspectre
8df25f9400 VS: connect /Y- compiler option with "Not Using Precompiled Headers"
f1223e34c6 VS: Add v140 flag table entries for `-Zc:inline[-]`
efc90eed77 VS: Fix regressed mapping for the cl `/Os` compiler flag
36b7fc7db6 VS 14: Add flag map for -std= to CppLanguageStandard tag in project files
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2611
2018-12-07 08:37:14 -05:00
Stephan Szabo
6d855fbf44 Replace header flag tables with json reading
Stop loading flag tables from header files and instead load the flag table
information from json files in Templates/MSBuild/FlagTables.
2018-11-28 07:43:31 -08:00
Harry Mallon
f54d28a838 VS: Avoid crash with VS 2015 when all SDKs are higher than 10.0.14393.0
Move the filter added by commit v3.13.0-rc1~72^2~2 (VS: Do not select a
Windows SDK too high for current VS version, 2017-08-07, committed
2018-09-17) to before our check that the remaining list is empty.
Otherwise we crash when dereferencing the first entry of an empty
vector.

Also add a comment explaining where 10.0.14393.0 came from.

Fixes: #18633
2018-11-26 13:42:50 -05:00
Gilles Khouzam
83ddc4d289 VS: Do not select a Windows SDK too high for current VS version
Add an internal API for the maximum Windows 10 SDK version supported by
a toolset.  For Visual Studio 14 2015 that would be the version
"10.0.14393.0".

Fixes: #17788
2018-09-17 13:07:40 -04:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Vitaly Stakhovsky
92c7b52607 VS: Use range-based 'for' loops in generator code
Use `auto` for complex types.
2017-12-21 14:52:49 -05:00
Brad King
0b33aee48b Use C++11 override instead of CM_OVERRIDE
We now require C++11 support including `override`.  Drop use of
the old compatibility macro.  Convert references as follows:

    git grep -l CM_OVERRIDE -- '*.h' '*.hxx' '*.cxx' |
      xargs sed -i 's/CM_OVERRIDE/override/g'
2017-09-15 10:06:41 -04:00
Ben Boeckel
80f59ee602 cmGlobalVisualStudio14Generator: notify when the SDK version doesn't match
When requesting an SDK version which is not suitable (e.g., missing
`windows.h`), CMake will use the next-best SDK version. Output a message
when CMake chooses something different than the requested SDK version.

See #16895.
2017-07-13 08:10:57 -04:00