Commit Graph

950 Commits

Author SHA1 Message Date
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Brad King
1a1508c8b8 Merge topic 'modernize-use-auto'
d25a5a7ec9 clang-tidy: modernize-use-auto

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3783
2019-09-12 09:15:38 -04:00
Brad King
46629d6a49 Merge topic 'fileapiAddMoreBacktraces'
30006e199b fileapi: add backtraces for compile/link options
291c83f063 cmLocalGenerator: Add GetTargetCompileFlags overload with backtraces
8e973b8e8d cmLocalGenerator: Add GetTargetFlags overload with backtraces
4d5bbb7704 cmLocalGenerator: Add GetStaticLibraryFlags overload with backtraces
1f6a436bf4 cmLocalGenerator: Add AddCompileOptions overload with backtraces
5355a60fd0 cmLocalGenerator: Add AppendCompileOptions overload with backtraces
a20d2c85d0 cmLocalGenerator: Add AppendFlags overload with backtraces
b13207910e cmLocalGenerator: Clarify AddCompileOptions filter logic
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3775
2019-09-11 11:38:58 -04:00
Regina Pfeifer
d25a5a7ec9 clang-tidy: modernize-use-auto
Set the MinTypeNameLength option to an impossibly high value in order
to limit the diagnostics to iterators.  Leave new expressions and cast
expressions for later.
2019-09-10 22:21:41 +02:00
Brad King
054d626c9c Merge topic 'MoveIfDifferent'
5b96fd5b81 use cmSystemTools::MoveFileIfDifferent()
5eaf1e1be2 cmSystemTools: introduce MoveFileIfDifferent()

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3794
2019-09-10 10:58:53 -04:00
Justin Goshi
291c83f063 cmLocalGenerator: Add GetTargetCompileFlags overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
8e973b8e8d cmLocalGenerator: Add GetTargetFlags overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
4d5bbb7704 cmLocalGenerator: Add GetStaticLibraryFlags overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
1f6a436bf4 cmLocalGenerator: Add AddCompileOptions overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
5355a60fd0 cmLocalGenerator: Add AppendCompileOptions overload with backtraces 2019-09-10 10:45:41 -04:00
Brad King
c2ead49451 Merge topic 'local-var'
4d71bea02c cmLocalGenerator::AddConfigVariableFlags: optimize string construction

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3793
2019-09-10 10:02:00 -04:00
Justin Goshi
a20d2c85d0 cmLocalGenerator: Add AppendFlags overload with backtraces 2019-09-09 09:43:34 -04:00
Justin Goshi
b13207910e cmLocalGenerator: Clarify AddCompileOptions filter logic 2019-09-09 09:43:34 -04:00
Justin Goshi
ca7b90dcf2 cmLocalGenerator: Use local variables to collect flags 2019-09-09 09:43:34 -04:00
Justin Goshi
eac8700c78 cmLocalGenerator: Improve local variable names 2019-09-09 09:43:34 -04:00
Brad King
922482dd3a Merge topic 'cuda_resolve_device_symbols_on_static_lib_collect_deps_properly'
2d7bb13da7 CUDA: static lib device linking computes required static libs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3748
2019-09-09 09:41:32 -04:00
Rolf Eike Beer
5b96fd5b81 use cmSystemTools::MoveFileIfDifferent()
This is better than doing CopyFileIfDifferent() followed by RemoveFile() in
two ways:

 - it is more efficient, as it avoids disk I/O for the data, even if the
   files here are usually small
 - it is atomic, so an abort during the copy will not leave a destination file
   with partial data behind
2019-09-09 10:34:08 +02:00
Rolf Eike Beer
4d71bea02c cmLocalGenerator::AddConfigVariableFlags: optimize string construction 2019-09-09 08:15:32 +02:00
Robert Maynard
2d7bb13da7 CUDA: static lib device linking computes required static libs
Previously the CMake didn't compute the required set of libraries
needed to properly device link a static library when
CUDA_RESOLVE_DEVICE_SYMBOLS was enabled.
2019-09-05 10:51:02 -04:00
Brad King
5acf0de1fe cmLocalGenerator: Remove AppendFlags 'const char*' overload
Update call sites to ensure the `std::string` argument can be
constructed safely.
2019-09-05 10:31:56 -04:00
Brad King
ac4d6d4a9d Merge topic 'unity-build'
7786a05c70 Unity build: Add XCode support
1353802af3 Unity build: Add unit tests
8dfeb5d278 Unity build: Add support for Visual Studio generator
7114c141e2 Unity build: Add support for Ninja and Makefile generators

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Acked-by: Evgeniy Dushistov <dushistov@mail.ru>
Acked-by: Viktor Kirilov <vik.kirilov@gmail.com>
Merge-request: !3611
2019-09-05 08:36:06 -04:00
Regina Pfeifer
62e5f72289 clang-tidy: Replace typedef with using 2019-09-03 13:21:26 -04:00
Brad King
1f7bd00322 Merge topic 'add-non-empty-configurations-getter'
10507c6dc0 cmMakefile: Add configurations getter with empty configuration default

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3759
2019-09-03 09:42:15 -04:00
Cristian Adam
7786a05c70 Unity build: Add XCode support 2019-08-30 20:39:37 +02:00
Daniel Eiband
10507c6dc0 cmMakefile: Add configurations getter with empty configuration default 2019-08-30 13:52:13 +02:00
Daniel Eiband
2d888e3390 cmSourceFile: Rename mutating GetFullPath() overload
Rename mutating GetFullPath() overload to ResolveFullPath().
2019-08-29 22:51:58 +02:00
Cristian Adam
8dfeb5d278 Unity build: Add support for Visual Studio generator
It works as expected in Visual Studio.

Visual Studio 2017 will (partially) benefit from the build in
support for unity builds. The custom unity sources are used, because
the build in support doesn't allow batching of certain number of
files. It can do only batching by directory.
2019-08-29 16:45:42 +02:00
Cristian Adam
7114c141e2 Unity build: Add support for Ninja and Makefile generators 2019-08-29 16:44:09 +02:00
Brad King
fa36e2151d Merge topic 'precompile-headers'
8da78d4efe Precompile headers: Update documentation
5772930164 Precompile headers: Add unit tests
519606704e Precompile headers: Add support for Visual Studio generators
28be170fbc Precompile headers: Add support for Xcode generator
b8626261e9 Precompile headers: Add methods to generate PCH sources
375d01c680 PCH: add example/test
9b6797e71d PCH: add target_precompile_headers command
0467a2f91b PCH: add PRECOMPILE_HEADERS to special properties

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Acked-by: Ivan171 <heavenandhell171@gmail.com>
Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Acked-by: Steve Mokris <smokris@softpixel.com>
Acked-by: Evgeniy Dushistov <dushistov@mail.ru>
Acked-by: Danila Malyutin <flashmozzg@gmail.com>
Acked-by: Viktor Kirilov <vik.kirilov@gmail.com>
Acked-by: Lucas Zhao <zhaopf6@163.com>
Merge-request: !3553
2019-08-29 09:38:21 -04:00
Cristian Adam
b8626261e9 Precompile headers: Add methods to generate PCH sources
Co-Author: Daniel Pfeifer <daniel@pfeifer-mail.de>
2019-08-28 11:47:40 -04:00
Brad King
613ac3e7d5 Merge topic 'swift-version'
369c48ee43 Swift: honour `-swift-version` in Ninja generator

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3685
2019-08-27 10:57:26 -04:00
Saleem Abdulrasool
369c48ee43 Swift: honour -swift-version in Ninja generator
Swift has supported `CMAKE_Swift_LANGUAGE_VERSION` and
`Swift_LANGUAGE_VERSION` but didn't apply that to Ninja generated
targets.  Consider the property when calculating the flags.
2019-08-26 11:38:40 -04:00
Sebastian Holtermann
aaf59120bf Source sweep: Replace cmExpandList with the shorter cmExpandedList
This replaces the code pattern
```
std::vector<std::string> args;
cmExpandList(valueStr, args, ...)
```
with
```
std::vector<std::string> args = cmExpandedList(valueStr, ...)
```
2019-08-23 17:07:49 +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
Brad King
337be1507d Merge topic 'isolate-declarations'
d331021255 clang-tidy: isolate declarations for readability

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3704
2019-08-22 10:23:34 -04:00
Brad King
bfe0ea2d98 Merge topic 'cm-contains'
2dfc52675c cmAlgorithms: Add cmContains

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Sebastian Holtermann <sebholt@web.de>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Merge-request: !3700
2019-08-21 11:52:06 -04:00
Regina Pfeifer
d331021255 clang-tidy: isolate declarations for readability 2019-08-21 00:20:49 +02:00
Regina Pfeifer
2dfc52675c cmAlgorithms: Add cmContains
Also, use the new function where applicable.
2019-08-19 20:01:39 +02: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
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Kyle Edwards
17b66165f6 Merge topic 'strcat-localgenerator'
62659100aa cmLocalGenerator: Use cmStrCat

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Sebastian Holtermann <sebholt@web.de>
Merge-request: !3671
2019-08-13 09:53:47 -04:00
Kitware Robot
54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP 2019-08-09 10:41:44 -04:00
Regina Pfeifer
62659100aa cmLocalGenerator: Use cmStrCat
Grep for '[A-Z]_";' to find places that could benefit from cmStrCat.
2019-08-09 10:58:00 +02:00
Sebastian Holtermann
18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation
Enables the clang-tidy test performance-inefficient-string-concatenation
and replaces all inefficient string concatenations with `cmStrCat`.

Closes: #19555
2019-08-05 17:21:00 +02:00
Sebastian Holtermann
f71f7ce3f0 cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h
This adds the `cmStringAlgorithms.h` header and moves all string functions
from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
2019-07-29 21:13:56 +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
Saleem Abdulrasool
59f2aa63e4 Swift: fix static library handling
Handle static libraries similar to shared libraries.  Do not pass along
the shared library flags raw as that will pass flags for the linker to
the driver which is incorrect.
2019-07-18 19:52:48 -07:00
Brad King
9f5c2040bf AIX: Explicitly compute executable exports for both XL and GNU
On AIX, symbols in executables must be exported in order to be visible
to modules (plugins) they load via `dlopen`.  Prior to policy `CMP0065`,
CMake linked all executables with flags to export symbols, but the NEW
behavior for that policy is to do so only for executables that have the
`ENABLE_EXPORTS` target property set.  In both cases, CMake has always
used the AIX linker option `-bexpall` option to export symbols from
executables.

This has worked fairly well with the XL compiler, but with the GNU
compiler it works only for C ABI symbols.  The reason is that `-bexpall`
does not export symbols starting in `_` but the GNU C++ ABI mangles all
symbols with a leading `_`.  Therefore we have only supported C ABI
plugins with the GNU compiler on AIX.  Some projects have tried to work
around this by replacing `-bexpall` with `-bexpfull`, but the latter
often exports symbols that we do not want exported.

Avoid using `-bexpall` for executables by instead using by our own
internal `ExportImportList` script to compute symbol export lists from
the object files to be linked into an executable.  Pass the explicitly
computed export list to the AIX linker's `-bE:...` option.  We already
do this for shared object exports.

Issue: #19163
2019-07-15 13:27:16 -04:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -04:00
Daniel Scharrer
d88b38d05d Normalize paths when checking for implicit include dirs
GCC replaces implicit include directories with user-supplied ones if
they point to the same directory, even if the path strings differ.
2019-06-22 23:09:17 +02:00