Commit Graph

202 Commits

Author SHA1 Message Date
NAKAMURA Takumi
0e58a5ea07 Source: Fix possible IWYU warnings in Windows generators 2021-11-20 00:50:33 +09:00
NAKAMURA Takumi
c46b041a3b cmLocalGenerator: Simplify Add{Custom,Utility}Command 2021-11-18 12:02:38 -05:00
NAKAMURA Takumi
9b31a97748 cmCustomCommand: Move constructor arguments to individual setters
Make `cmCustomCommand` have just only default constructor.
Use each setter instead.  This follows the builder pattern.

Introduce `cc::SetOutputs(std::string output)`.
This will be used later, as substitution for `cc::SetOutputs({output})`.
2021-11-18 12:02:37 -05:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Brad King
c46b265839 VS: Add Visual Studio 17 2022 generator
Fixes: #22339
2021-06-25 12:45:44 -04:00
Kyle Edwards
f01f10e8fb cmCustomCommand: Record value of CMP0116 at time of creation 2021-02-23 09:14:31 -05:00
Brad King
422d9a0ab2 Factor out generator checks for filtering out interface libraries
Add a `cmGeneratorTarget::IsInBuildSystem` helper method to tell
generators whether a target should participate in the generated build
system.
2020-07-23 13:31:44 -04:00
Vitaly Stakhovsky
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string 2020-07-14 15:18:59 -04:00
Brad King
05e0ff3c73 Merge topic 'vs-sln-version-16'
b69010b719 VS: Fix .sln support for VS Version Selector with VS 2019

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4844
2020-06-03 06:03:43 -04:00
Brad King
b69010b719 VS: Fix .sln support for VS Version Selector with VS 2019
VS 2019 changed the naming pattern used by 2015 and 2017.

Fixes: #20783
2020-06-02 10:30:33 -04:00
Brad King
1174efb6f9 Merge topic 'vs-sln-version' into release-3.17
88ad02f1ec VS: Restore .sln support for VS Version Selector

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4765
2020-05-20 09:03:23 -04:00
Brad King
4dfc7846f4 Merge topic 'vs-sln-version'
88ad02f1ec VS: Restore .sln support for VS Version Selector

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4765
2020-05-20 09:03:23 -04:00
Brad King
88ad02f1ec VS: Restore .sln support for VS Version Selector
Since commit 3b51343ea1 (VS: Emit UTF-8 BOM for generated solution files,
2019-08-19, v3.16.0-rc1~237^2) the `.sln` file does not work with the
VS Version Selector.  Add a newline after the BOM to restore support.

Fixes: #20725
2020-05-19 08:24:37 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -04:00
Justin Goshi
bc877a7e94 Add support to indicate UTF-8 custom command pipe output encoding
Adds a flag to indicate that pipe output from a custom command should be
interpreted as UTF-8 encoded. This change does not introduce a public
way to set the flag, but generators that create internally-generated
commands know if they are calling cmake, which uses UTF-8 pipes.

MSBuild added support for interpreting output of PreBuildEvent,
PreLinkEvent, PostBuildEvent, and CustomBuildStep as UTF-8. This change
will appear in Visual Studio 16.6 Preview 3. It is opt-in, and you need
to add the StdOutEncoding tag. MSBuild treats these as property bags so
if we emit the tag for earlier versions of Visual Studio it would be
safely ignored. This change emits the StdOutEncoding tag and sets it to
UTF-8 whenever the custom command UTF-8 pipe flag is set. This fixes
globalization issues when the output from cmake contained characters
that required MSBuild to interpret as UTF-8 before displaying them.
2020-04-13 12:54:47 -07:00
Vitaly Stakhovsky
aba23c747b cmMakefile::GetProperty: return cmProp 2020-04-01 10:56:34 -04:00
Kyle Edwards
7abc3d61ac Ninja Multi-Config: Fix issue with framework dependencies and Autogen
Fixes: #20345
2020-02-17 08:24:57 -05:00
Vitaly Stakhovsky
bbc07e4561 Source: use std::string in place of const char* 2020-01-29 14:31:01 -05:00
Daniel Eiband
777ceaea94 cmMakefile: Delay custom command creation
Move custom command creation to cmLocalGenerator and dispatch custom
commands in cmMakefile to generate time.  Generators add custom commands
using the new methods provided by cmLocalGenerator.

Issue: #12877
2019-11-24 20:32:43 +01:00
Daniel Eiband
96e5042e46 cmCustomCommand: Explicitly pass backtrace on construction 2019-11-24 20:13:23 +01:00
Marc Chevrier
f93385283f cmLocalGenerator: modernize memory management 2019-11-11 16:41:13 +01:00
Brad King
55a0bebdd3 VS: Add support for per-config sources
Since commit 97cc29c766 (VS: Teach generators how to mark per-config
source files, 2017-04-10, v3.9.0-rc1~268^2~2) the VS generators have
known how to generate per-config sources.  We've now converted most
other code paths to support per-config sources, so drop the check
that disallows it.

This leaves only per-config support for precompiled headers and unity
build transformations, but those are optional features that can be
addressed later.

Fixes: #18233
Issue: #19789
2019-10-17 14:05:39 -04:00
Brad King
bcaecf6bcd Teach check for single-language targets to consider all configurations 2019-10-17 14:03:54 -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
dce58afd30 Merge branch 'backport-3.15-fix-EXCLUDE_FROM_ALL-subdir-all'
Resolve conflicts with changes since the 3.15 series:

* Convert `cmSystemTools::IsOn` => `cmIsOn`.
* Move one "EXCLUDE_FROM_ALL" target property logic fix to
  its new location in `cmMakefile::AddNewUtilityTarget`.
2019-09-30 09:34:57 -04:00
Brad King
05d7ca14e9 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' 2019-09-30 09:19:21 -04:00
Brad King
b3b1c7bf3a Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL
The "all" target in each directory is supposed to have targets from that
directory even if the directory itself is marked `EXCLUDE_FROM_ALL` in
its parent.  This was broken by commit dc6888573d (Pass EXCLUDE_FROM_ALL
from directory to targets, 2019-01-15, v3.14.0-rc1~83^2) which made the
participation of a target in "all" independent of context.  Revert much
of the logic change from that commit to restore the old behavior.  Then
re-implement the behavior intended by the commit to keep its test
working.  Extend the test to cover the old behavior too.

Fixes: #19753
2019-09-30 09:18:20 -04:00
Daniel Eiband
5a06efda05 cmMakefile: Remove AddUtilityCommand overload without byproducts 2019-09-26 10:04:03 -04:00
Daniel Eiband
f151a57705 cmMakefile: Move enumerations into new header
The enumerations will also be used in cmLocalGenerator.
2019-09-26 10:02:06 -04:00
Brad King
a29b8d285e Merge topic 'fix-vsmacro-access-violation'
7847fef510 VS: Fix access violation when calling Visual Studio macro

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3853
2019-09-26 09:49:56 -04:00
Daniel Eiband
7847fef510 VS: Fix access violation when calling Visual Studio macro
Fixes: #19730
2019-09-24 17:44:28 +02:00
Daniel Eiband
f4afcd5c6b VS: Remove call to ConvertToWindowsExtendedPath with result discarded
Remove call to ConvertToWindowsExtendedPath.  The call has no side effect and
the return value is discarded.
2019-09-21 12:56:10 +02:00
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04:00
Daniel Eiband
7f3ecbe7d7 cmCustomCommandLine: Provide command line make functions
Reduce boilerplate necessary to create custom command lines by introducing and
applying cmMakeCommandLine and cmMakeSingleCommandLine functions.
2019-09-16 20:45:41 +02:00
Brad King
89479bde94 Merge topic 'pvs-cleanup'
7fe3e874d5 cmCPackLog: Fix support for multiple log message tags
74f2c0ea56 cmCTestTestHandler: Remove extra layer of parentheses
7c2767ef3b cmCTestMultiProcessHandler: Explain testRun ownership in comments
303e813438 CTest: Simplify some boolean conditions
51565abe79 cmMessageCommand: Remove extra layer of parentheses
b1cfaf7b91 cmVSSetupHelper: Remove unused SmartBSTR copy operations
3f4c4e7afe cmVSSetupHelper: Fix SmartBSTR copy operations
a8ca5aea94 cmMakefileTargetGenerator: Check for null before using a pointer
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Acked-by: Artalus <artalus-mail@yandex.ru>
Merge-request: !3715
2019-08-26 10:51:11 -04:00
Sebastian Holtermann
3b2b02825d Source sweep: Replace std::ostringstream when used with a single append
This replaces `std::ostringstream`, when it is written to only once.
If the single written argument was numeric, `std::to_string` is used instead.
Otherwise, the single written argument is used directly instead of the
`std::ostringstream::str()` invocation.
2019-08-23 18:52:33 +02:00
Brad King
a7aade8419 cmGlobalVisualStudioGenerator: Fix buffer sizes used with RegEnumKeyExW
In commit 0b9906c2fb (Windows: Use wide-character system APIs,
2013-12-04, v3.0.0-rc1~254^2) several buffer size computations had to be
updated to multiply by `sizeof(wchar_t)`, but for RegEnumKeyExW we were
already computing the correct number of characters with a division which
was accidentally converted to a multiplication.  Use `cm::size` to
compute the number of characters in the buffer instead.

Issue: #19610
2019-08-22 13:06:15 -04:00
Brad King
f6211f57d6 cmGlobalVisualStudioGenerator: Fix buffer sizes used RegQueryValueExW
In commit 0b9906c2fb (Windows: Use wide-character system APIs,
2013-12-04, v3.0.0-rc1~254^2) several buffer size computations had to be
updated to multiply by `sizeof(wchar_t)`, but some for RegQueryValueExW
were incorrect because the number of bytes was already computed.

Issue: #19610
2019-08-22 11:01:50 -04: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
Brad King
3402e6cf82 Merge topic 'vs-sln-bom'
3b51343ea1 VS: Emit UTF-8 BOM for generated solution files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3705
2019-08-21 11:53:23 -04:00
Justin Goshi
3b51343ea1 VS: Emit UTF-8 BOM for generated solution files
We write UTF-8-encoded content to the `.sln` files, so tell VS to read
them as such.

Fixes: #19594
2019-08-20 11:09:31 -04:00
Sebastian Holtermann
20e580be01 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn
This replaces invocations of

- `cmSystemTools::IsInternallyOn` with `cmIsInternallyOn`
- `cmSystemTools::IsNOTFOUND` with `cmIsNOTFOUND`
- `cmSystemTools::IsOn` with `cmIsOn`
- `cmSystemTools::IsOff` with `cmIsOff`
2019-08-17 12:14:14 +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
Leonid Pospelov
75643755a1 cmGlobalVisualStudioGenerator: remove redundant variables 2019-04-24 17:18:11 +03:00
Leonid Pospelov
615fb2633c cmGlobalVisualStudioGenerator: use cmJoin to join the filenames 2019-04-23 00:54:05 +03:00
Leonid Pospelov
30c98db61b cmGlobalVisualStudioGenerator: use auto instead of iterator types 2019-04-23 00:52:33 +03:00
Brad King
cb23f2ac8b Merge topic 'vs-default-platform'
db02be85a0 VS: Provide the default platform name to project code

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3246
2019-04-22 07:38:33 -04:00
Brad King
db02be85a0 VS: Provide the default platform name to project code
The value of `CMAKE_VS_PLATFORM_NAME` is computed by Visual Studio
generators based on `CMAKE_GENERATOR_PLATFORM` or some default.
Prior to the VS 2019 generator, the default was always `Win32`.
However, for the `Visual Studio 16 2019` generator, the default is
based on the host platform.

Store the default in a new `CMAKE_VS_PLATFORM_NAME_DEFAULT` variable for
use by project code.  This is particularly useful in toolchain files
because they are allowed to set `CMAKE_GENERATOR_PLATFORM` and so
`CMAKE_VS_PLATFORM_NAME` is not yet known.  Of course the toolchain file
author knows whether it will set `CMAKE_GENERATOR_PLATFORM`, and if not
then `CMAKE_VS_PLATFORM_NAME_DEFAULT` provides the platform name that
will be used.

Fixes: #19177
2019-04-19 07:46:13 -04:00
Sebastian Holtermann
db182eb160 cmTarget: Move member *Commands to impl 2019-03-23 22:22:34 +01:00
Brad King
dbd3b1ac90 Merge topic 'vs-fortran-rc'
0b82f56ac6 VS: Fix Fortran target type selection with RC sources

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3050
2019-03-04 08:35:46 -05:00