Commit Graph

101 Commits

Author SHA1 Message Date
Brad King
163cc8bbdd VS: Convert WriteSLNHeader to non-virtual lookup table 2019-01-10 07:52:51 -05:00
Brad King
03f74a16cd VS: Convert GetIDEVersion to non-virtual table lookup 2019-01-10 07:52:48 -05:00
Brad King
d07f453f39 VS: Convert GetToolsVersion to non-virtual table lookup 2019-01-10 07:51:47 -05:00
Vitaly Stakhovsky
77d83568e0 cmGlobalVisualStudioGenerator::GetIDEVersion(): const added 2019-01-02 08:25:49 -05:00
Vitaly Stakhovsky
94632087b2 Add missing override 2018-12-30 12:32:55 -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
Niels Dekker
567fabe88e IPO: INTERPROCEDURAL_OPTIMIZATION (LTCG) for Visual Studio
Add IPO support for Visual Studio (which is referred to by VS as
"Link Time Code Generation" and "Whole Program Optimization"), for
VS version >= 10.  This allows CMake/VS users to enable IPO by setting
property `INTERPROCEDURAL_OPTIMIZATION`.

Fixes: #16748
2018-09-17 10:53:10 -04:00
Basil Fierz
3c4698da3a VS: Allow toolset version selection to specify default toolset
Teach the feature added by commit v3.12.0-rc1~38^2 (VS: Add option to
select the version of the toolset used by VS 2017, 2018-05-19) to accept
the default toolset version in addition to older versions.  If the
default toolset version is supplied, simply clear it so the default will
be used.

Fixes: #18107
2018-06-24 10:36:03 -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
Brad King
958191a95c Merge topic 'vs-toolset-version'
5f13168419 VS: Add option to select the version of the toolset used by VS 2017

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Francisco Facioni <fran6co@gmail.com>
Merge-request: !2093
2018-05-30 10:19:21 -04:00
Basil Fierz
5f13168419 VS: Add option to select the version of the toolset used by VS 2017
Add new `version=` parameter in the toolset setting to select the
version.  Add variable `CMAKE_VS_PLATFORM_TOOLSET_VERSION` to hold the
version, if one is set (blank indicates default).

Fixes: #17549
2018-05-29 10:12:59 -04:00
Florian Maushart
1ab3881ec9 cmake: Add options for parallel builds to --build mode
While we already support `cmake --build . -- -j`, the options after `--`
are specific to the native build tool.  Add new options `--parallel
[<N>]` and `-j [<N>]` to abstract this and map to the proper option
for the native build tool.
2018-05-25 09:42:20 -04:00
Vitaly Stakhovsky
cfe4e2db1f VS: Use 'override' keyword for overridden methods in generator classes
The corresponding 'virtual' removed.
2017-12-15 21:17:49 -05:00
Vitaly Stakhovsky
907bc35437 VS: Emit "utf-8" encoding as lowercase in .vcxproj headers
Match the XML preamble generated by VS 2010 and later.
2017-12-14 08:27:48 -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
Brad King
ae44496e2b VS: Fix GenerateDebugInformation values for v140 and v141 toolsets
When VS 2015 was first released, its new v140 toolset came with a
`link.xml` file that changed the `GenerateDebugInformation` boolean
(`false` and `true`) value from earlier toolsets to an enumeration
consisting of the possible values `No`, `Debug`, and `DebugFastLink`.

We first adapted to this in commit v3.4.2~2^2 (VS: Fix VS 2015 .vcxproj
file value for GenerateDebugInformation, 2016-01-08), but that broke
older toolsets that still expected the boolean.  Then commit
v3.6.0-rc1~295^2~1 (VS: Fix VS 2015 .vcxproj debug setting for older
toolsets, 2016-02-24) added a hack to fix up the value based on the
toolset in use.  Several follow-up commits fixed this for more older
toolsets because our flag table was at the time based on the generator
in use rather than the toolset in use.

Since commit v3.8.0-rc1~396^2 (VS: Choose flag map based on the toolset
name, 2016-10-17) we use a flag table based on the toolset, so the fixup
hack should not be needed.  We had to keep it around only due to our
default value for GenerateDebugInformation (`false` or `No`) still being
based on the generator instead of the toolset.

A VS 2015 update was released that changed the v140 toolset `link.xml`
file back to using `false` and `true` for the `GenerateDebugInformation`
enumeration variants previously known as `No` and `Debug`.  In order to
know which pair to use, we need to parse the `link.xml` file for the
current toolset.

Switch back to using `false` and `true` unconditionally in our
`GenerateDebugInformation` flag table entries and default value.  With
that plus the toolset-based flag table, we now get incorrect values for
`GenerateDebugInformation` only when using a v140 toolset from an older
VS 2015 installation.  Detect this case by parsing `link.xml` and add
special logic to convert `false` and `true` to `No` and `Debug` to
satisfy the older toolset specification.

Inspired-by: Ian Hojnicki <nullref@live.com>
Fixes: #17020
2017-06-28 08:55:40 -04:00
Brad King
041ebda25b VS: Add placeholder CUDA flag tables
The CUDA Toolkit's VS integration defines abstractions for both options
to `nvcc` and options to pass through `-Xcompiler` to the host MSVC.
We need a separate flag table to parse each set of flags into the
corresponding abstractions.  Add empty placeholders for these tables.
2017-03-10 10:19:55 -05:00
Brad King
13433b1357 VS: Record in global generator whether CUDA is enabled 2017-03-10 10:19:55 -05:00
Brad King
5164e9a651 VS: Provide an option to specify CUDA toolset version
The NVIDIA CUDA Toolkit provides MSBuild toolset files for integration
with Visual Studio.  Multiple versions may be installed so we need a way
to tell our VS generators which CUDA toolset to use.  Extend the
`CMAKE_GENERATOR_TOOLSET` specification to provide a `cuda=...` field
specifying the version number.
2017-03-10 10:19:53 -05:00
Brad King
83bf980c96 VS: Find the MSBuild value for VCTargetsPath
Run MSBuild on a simple `.vcxproj` file to extract the location of the
toolset definitions.  This will later be useful for looking at available
BuildCustomizations.
2017-03-10 10:19:52 -05:00
Brad King
f773933f26 VS: Refactor generator toolset parsing
We parse `CMAKE_GENERATOR_TOOLSET` values of the forms:

* `toolset`
* `toolset,host=x64`
* `host=x64`

Generalize the parsing to support the forms:

* `toolset`
* `toolset[,key=value]*`
* `key=value[,key=value]*`

Disallow duplicate keys.  Require all but the first field to
be of `key=value` form.
2017-02-15 08:15:37 -05:00
Evgeny Fimochkin
5ba2c9e5e0 VS: Add support for ASM_NASM language
Fixes: #16469
2017-02-07 13:20:52 -05:00
Michael Stürmer
9b06c22648 VS: Add flag tables for C#
Add these (currently unused) tables in preparation for `.csproj`
generation support.  Populate the tables for every version with a set of
initial values that work well for me with VS 12 and VS 14.  Later we may
need to generate them more thoroughly from MSBuild `.xml` files.
2016-12-01 16:45:34 +01:00
Don Olmstead
69fc7bf87d VS: Choose flag map based on the toolset name
MSBuild interprets the `.vcxproj` content based on the `PlatformToolset`
setting, so our reverse mapping needs to be based on that setting too.
For VS 2010 and above, choose the flag map to match the toolset name
rather than the generator VS version.

Issue: #16153
2016-10-25 09:46:21 -04:00
Don Olmstead
e2ed9a7092 VS: Move toolset flag table lookup to global generator
Move `Get*FlagTable` methods to the global generator and have each VS
generator version pre-populate its default flag table.
2016-10-25 09:19:49 -04:00
Brad King
584ab5285b VS: Add internal API to get platform toolset as string 2016-10-25 09:19:49 -04:00
Brad King
2d3aa94225 cmGlobalGenerator: Allow FindMakeProgram to fail
Revise its signature to return `bool` so that it can fail and abort
configuration early.
2016-10-20 10:37:27 -04:00
Brad King
d079e71c29 VS: Provide an option to use x64 host tools
Visual Studio provides toolchains that are themselves built for 32-bit
or 64-bit host architectures.  By default it uses the 32-bit tools, but
it can be told to prefer the 64-bit tools on 64-bit hosts.  Extend the
`CMAKE_GENERATOR_TOOLSET` specification to provide a way to request
use of the 64-bit host tools.

Closes: #15622
2016-10-14 09:22:26 -04:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* 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.
2016-05-16 16:05:19 -04:00
Brad King
571bedec29 VS: Ignore USE_FOLDER property on VS versions that do not support it
Solution folders are supported on VS 8 and above in the full versions
and on VS 11 and above in the express versions.
2016-04-26 08:22:27 -04:00
Brad King
0c58d2d0fd VS: Detect VS 8 and 9 Express editions 2016-04-26 08:16:19 -04:00
Stephen Kelly
459c891088 VS10: Port to cmGeneratorTarget. 2015-10-24 09:19:55 +02:00
Stephen Kelly
a9588e90bb VisualStudio10: Initialize the LongestSource at generate time.
There is no need to initialize it at compute time.
2015-10-05 18:43:17 +02:00
Gilles Khouzam
3f077996f5 VS: Add support for selecting the Windows 10 SDK (#15670)
Teach the VS 2015 generator to produce a WindowsTargetPlatformVersion
value.  Use the CMAKE_SYSTEM_VERSION to specify the version and if not
set choose a default based on available SDKs.  Activate this behavior
when targeting Windows 10.

Co-Author: Brad King <brad.king@kitware.com>
2015-10-02 09:53:25 -04:00
Gilles Khouzam
5dfc4c5f50 VS: Add hook to initialize Windows platform settings
Give VS 10+ generators a chance to choose Windows platform settings just
as they already can for WindowsCE, WindowsStore, and WindowsPhone.
2015-10-02 09:43:24 -04:00
Stephen Kelly
ff8ac8ee6a cmLocalGenerator: Create from already-constructed cmMakefile.
Don't manage the lifetime of the cmMakefile with cmLocalGenerator.
2015-08-28 18:44:39 +02:00
Stephen Kelly
9b6a743b80 cmLocalGenerator: Remove Parent pointer. 2015-08-28 18:44:38 +02:00
Stephen Kelly
5edb335485 cmGlobalGenerator: Virtualize the Compute step and override it. 2015-07-30 08:28:31 +02:00
Stephen Kelly
3b880a0741 cmLocalGenerator: Require a valid cmState::Snapshot in the ctor.
Refactor the local generator creation API to accept a
cmState::Snapshot.  Adjust MakeLocalGenerator to use the 'current'
snapshot in cases where there is no parent.  Create the snapshot
for subdirectories in cmMakefile::AddSubdirectory.

This means that snapshots are now created at the point of extending the tree,
as appropriate, and independently of the cmLocalGenerator and cmMakefile they
represent the state for.
2015-05-27 09:18:32 -04:00
Stephen Kelly
c7b79aa16a cmGlobalGenerator: Require a cmake instance in ctor.
It is required anyway, so this makes it explicit.
2015-05-27 09:18:31 -04:00
Stephen Kelly
a48aebcb67 cmLocalGenerator: Require a parent in the constructor.
Pass the parent though cmGlobalGenerator::CreateLocalGenerator.

This will make it easy to initialize state scopes independent of
cmMakefile.
2015-04-28 07:50:52 +02:00
Brad King
885ab9ab37 VS: Drop reload macros for VS >= 10 (#11258,#14680)
We never implemented them for VS 11 (2012), 12 (2013), or 14 (2015).
For VS 10 (2010) the reload macro does not work correctly when run from
inside a build launched through the IDE because stopping the build kills
the CMake that is driving the reload.  Fortunately VS >= 10 know how to
reload the whole solution anyway.
2015-04-15 09:58:42 -04:00
Gregor Jasny
ce935ebe50 cmake: Teach --build to honor CMAKE_VERBOSE_MAKEFILE for Ninja
The Ninja build system does not support a in-file verbositiy switch.
Instead teach 'cmake --build' to extract the CMAKE_VERBOSE_MAKEFILE
setting and pass it as an optional '-v' argument to Ninja.  This can
serve as a reasonable fallback.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2015-02-26 09:51:11 -05:00
Brad King
d526ebc603 Merge topic 'vs-check-phone-store-tools'
689cd0d4 VS: Do not produce WinMD file for OBJECT libraries (#15228)
b20a32ac VS: Improve error messages when compiler is not detected (#15228)
2014-11-18 09:12:34 -05:00
Gilles Khouzam
b20a32ac73 VS: Improve error messages when compiler is not detected (#15228)
CMake requires both the Desktop SDK and the correct platform SDK
(Windows Phone or Windows Store) to be installed when targeting the
Windows mobile platforms.  Verify that the right platform components are
installed and give a more detailed error message when something is
wrong.
2014-11-14 09:13:27 -05:00
Geoff Viola
bef23e8181 Fix some spelling errors in comments 2014-10-13 10:00:53 -04:00
Brad King
69e198dc3f VS: Generate Nsight Tegra project revision number
Nsight Tegra 2.0 will be revision '8'.  Generate this revision number
and add a NsightTegraUpgradeOnceWithoutPrompt element to tell newer
versions not to prompt when upgrading the generated project file.
2014-09-30 08:45:35 -04:00
Brad King
2f071466eb VS: Teach VS >= 10 to recognize CMAKE_SYSTEM_NAME 'Android'
When CMAKE_SYSTEM_NAME is 'Android', check for an installation of
'NVIDIA Nsight Tegra Visual Studio Edition' and generate .vcxproj
files for the "Tegra-Android" platform.  Also make the installed
version available in a CMAKE_VS_NsightTegra_VERSION variable.
2014-09-29 16:05:52 -04:00
Pascal Bach
a3298f7790 VS: Teach VS >= 10 generator about Windows CE
When CMAKE_SYSTEM_NAME is 'WindowsCE':

* Set the Subsystem and EntryPointSymbol accordingly.
* When CMAKE_SYSTEM_VERSION is 8.0 (Windows CE 2013),
  select the CE800 toolset by default.
2014-09-15 10:37:40 -04:00