186 Commits

Author SHA1 Message Date
Marc Chevrier
2faa3f6c55 Refactoring: Third-parties public headers are under cm3p prefix
Fixes: #20666
2020-05-07 12:06:08 +02:00
Rolf Eike Beer
48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix() 2020-03-23 22:41:43 +01:00
Brad King
4b062c77b3 Merge topic 'vs-version-for-unity'
9135954e2f VS: Do not use native unity builds on VS 2017 versions less than 15.8

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4324
2020-02-05 08:33:50 -05:00
Brad King
9135954e2f VS: Do not use native unity builds on VS 2017 versions less than 15.8
VS 2017 version 15.8 introduced support for unity builds implemented
in part by the `$(VCTargetsPath)/Microsoft.Cpp.Unity.targets` file.
Do not enable unity builds on VS 15 versions that do not have that file.

Fixes: #20284
2020-02-04 11:46:18 -05:00
Vitaly Stakhovsky
bbc07e4561 Source: use std::string in place of const char* 2020-01-29 14:31:01 -05:00
Marc Chevrier
a00960288b GlobalGenerator family: modernize memory management 2020-01-07 11:03:11 +01:00
Marc Chevrier
36c8cae2e8 cmLocalGenerator: modernize memory management 2019-12-10 00:24:06 +01:00
Alexander Boczar
548e9051a4 VS: Add support to override VCTargetsPath through toolset
Fixes: #19708
2019-10-15 13:28:45 -04:00
Alexander Boczar
99e83d4235 cmake: Teach --build mode to load CMAKE_GENERATOR_TOOLSET
Extend the `cmGlobalGenerator::SetGeneratorToolset` signature to
indicate when it is called from `cmake::build`.
2019-10-15 13:28:41 -04:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Brad King
cee20ad537 Merge topic 'vs-cuda-custom-dir'
25f29b9741 cuda: Adapted tests to work with modified cuda toolset
ee86770a3f cuda: Added docs for extended cuda toolset
0ad180d712 cuda: Extend cuda compiler detection to work with custom cuda path
55b0532128 cuda: Extend vs10 target generator to use custom cuda path
df0247a371 cuda: Extend toolset argument to accept path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3713
2019-09-03 09:34:46 -04:00
Benjamin Wozniak
df0247a371 cuda: Extend toolset argument to accept path
Previously cuda could only be used with cmake if it is
installed globally on the system. Sometimes this is not
possible (eg docker, packaging with conan, etc.).
Thus the cuda toolset argument is extended to take
a path to a cuda install directory.
2019-08-27 12:54:35 +02:00
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Rolf Eike Beer
da26b3be89 avoid adding multiple consecutive string literals to std::string
While at it change some single character additions to be of type char.
2019-08-18 14:22:11 +02:00
Sebastian Holtermann
7fbcc16dcd cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
This adds the following functions to `cmStringAlgorithms`:

- `cmIsSpace`
- `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`)
- `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`)
- `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to
  accept `cm::string_view`)
2019-08-05 11:25:30 +02: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
9c07cefee5 VS: Fix ApplicationTypeRevision in builtin check projects
Do not use the entire `CMAKE_SYSTEM_VERSION`, but rather the first two
components only.

Fixes: #19275
2019-05-21 08:50:37 -04:00
Brad King
639e14def6 VS: Factor out helper to compute ApplicationTypeRevision
This is the first two components of `CMAKE_SYSTEM_VERSION`.
2019-05-21 08:50:01 -04:00
Sebastian Holtermann
735c6f39d9 Fix invalid ///! doxygen comment line starts
In various places `///!` was used to start a comment line.  This is not valid
Doygen syntax.  This patch replaces `///!` comment starts with `//!`.
2019-03-31 11:27:12 +02:00
Bartosz Kosiorek
324d18bb34 cmake: Teach --build mode to support multiple targets
Fixes: #16136
2019-03-05 08:55:28 -05:00
Bartosz Kosiorek
fdeb364a84 cmGlobalGenerator: Change case of methods from GeneratedMakeCommand struct 2019-03-04 10:44:14 +01:00
Vitaly Stakhovsky
950c099d83 cmake: Progress functions use std::string param 2019-02-11 10:32:43 -05:00
Artur Ryt
01b2d6ab74 Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
2019-02-07 22:39:05 +01:00
Wil Stark
822697996e VS: Fix nowarn compiler option to accept warning numbers.
Warning disables are transferred to the VS IDE `<NoWarn>` node.

Fixes: #18878
2019-02-07 06:39:45 -05:00
Brad King
9620cb935a Merge topic 'add_consistent_verbose_build_flag'
66801f4d40 cmake: Add tests for verbose output to --build mode
439fe2e253 cmake: Add options for verbose output to --build mode
638667efa2 cmake: cmcmd.cxx fix "The arguments are" comments
3ca4402966 ctest: Fix --build-and-test without --build-target on Xcode
cb6c233ecc cmake: Add -hideShellScriptEnvironment xcodebuild option
1a45266cb5 cmGlobalGenerator: Add a class that represent the build command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2708
2019-01-29 09:19:39 -05:00
Brad King
0fd742a6ff VS: Teach VS 2019 generator to select host tools matching host arch
This generator is new so we can introduce the long-desired behavior
of selecting ``host=x64`` tools by default on x64 hosts.
2019-01-28 12:58:21 -05:00
Brad King
142e67eac6 VS: Use internal abstraction for VCTargetsPath host arch
Call our internal host architecture lookup method rather than directly
accessing a member used by its implementation.
2019-01-28 11:16:02 -05:00
Florian Maushart
439fe2e253 cmake: Add options for verbose output to --build mode
While we already support `VERBOSE` environment variable and
`CMAKE_VERBOSE_MAKEFILE` cached variable, add `-v` and `--verbose`
command line options to be able to activate verbose output directly from
CMake's build tool mode command line.

Also make `msbuild` honor the verbosity setting. `xcodebuild` still
doesn't honor the verbosity setting as it will need a policy added
and reworking of cmGlobalGenerator and cmsys to support
multiple command invocation.
2019-01-28 09:44:50 -05:00
Robert Maynard
1a45266cb5 cmGlobalGenerator: Add a class that represent the build command
This refactors a std::vector<std::string> into a class so that
we can extend the features to represent things such as multiple
chained commands in the future.
2019-01-25 08:20:02 -05:00
Brad King
40745ad35a Merge topic 'cmake-files-directory'
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h

Acked-by: Kitware Robot <kwrobot@kitware.com>
Rejected-by: vvs31415 <vstakhovsky@fastmail.com>
Merge-request: !2655
2019-01-25 08:01:26 -05:00
Bruno Manganelli
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h 2019-01-21 15:34:16 +00: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
Brad King
a8b447d72e Merge topic 'support_per_toolset_json_flags'
c8ba777f6d GlobalVisualStudio10Generator: Support non-standard toolset json flag files.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2772
2019-01-16 09:50:00 -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
57e48f16f2 VS: Add Visual Studio 16 2019 generator
Add this generator *without* support for specifying the target
architecture in the generator name.  cmake-gui will be taught
to provide a field for this, and command-line builds can use -A.

Also, teach this generator to select a default target architecture
based on the host architecture.

Fixes: #18689
Inspired-by: Egor Pugin <egor.pugin@gmail.com>
2019-01-11 11:04:51 -05:00
Brad King
b91f6f39f7 VS: Track explicitly when platform is specified in generator name 2019-01-10 09:38:35 -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
d07f453f39 VS: Convert GetToolsVersion to non-virtual table lookup 2019-01-10 07:51:47 -05:00
Stephan Szabo
c8ba777f6d GlobalVisualStudio10Generator: Support non-standard toolset json flag files.
If given a toolset that does not have an explicit mapping in
cmVisualStudio10ToolsetOptions, check for a json flag file using the
toolset name before trying the default toolset for the generator.
2019-01-03 13:25:19 -08: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
Brad King
98e4fbdc06 VS: Pass platform when invoking MSBuild
MSBuild expects a `/p:Platform=...` argument to tell it which platform
to build among those in the `.vcxproj` files.  We have not historically
had to do this because we generate only one platform.  However, when
a project uses `include_external_msproject` the included project file
may have other platforms.

Fixes: #18308
2018-09-25 13:27:13 -04:00
Vitaly Stakhovsky
50fbfee3a0 cmLocalGenerator: return directories as const std::string& 2018-08-27 15:48:57 -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
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
90086767dd cmGlobalVisualStudio10Generator: Use cmXMLWriter RAII helpers
This simplifies our XML generation code and avoids the need to disable
clang-format.
2018-03-09 10:11:11 -05:00