1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-11 16:38:08 +08:00

268 Commits

Author SHA1 Message Date
Marc Chevrier
8f839d02e3 cm::String: enhance compatibility with STL 2020-01-25 18:16:16 +01: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
Steve Wilson
9e66397c28 Languages: Add support for Objective-C++
Add entries in Modules and Modules/Platform to support
Objective-C++ compiler determination and identification.
Add Modules to check Objective-C++ compiler flags, source
compilations, program checks, etc...

Use OBJCXX as the designator of the language, eg:

project(foo OBJCXX)

Add various tests for Objective-C++ language features.  Add
tests to preserve C++ handling of .M and .mm files when
Objective-C++ is not a configured language.

Co-authored-by: Cristian Adam <cristian.adam@gmail.com>
2019-09-28 15:56:53 +02:00
Daniel Eiband
c12222db86 cmGeneratorExpression: Remove Evaluate overload by parameter re-ordering
Simplify by re-ordering parameters of cmCompiledGeneratorExpression::Evaluate
so that frequently used parameters are before less frequently used parameters.
This allows with little extra arguments to get rid of one Evaluate overload,
which makes it easier to implement the cmGeneratorExpression::Evaluate utility.
The latter would otherwise need four overloads.
2019-09-22 09:51:19 +02:00
Daniel Eiband
1811411fec cmGeneratorExpression: Move quiet flag to cmCompiledGeneratorExpression
The quiet flag is false for all but one call to Evaluate.  Make the quiet flag
a setter of cmCompiledGeneratorExpression to be able to remove it from the
Evaluate function signature.
2019-09-22 09:49:41 +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
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Regina Pfeifer
a1ddf2d0ba clang-tidy: Replace typedef with using
Automate the conversion with

  perl -i -0pe 's/typedef ([^;]*) ([^ ]+);/using $2 = $1;/g'

then manually fix a few places.
2019-09-04 18:03:01 +02:00
Brad King
37c671570c Merge topic 'source_sweep_ostringstream_single'
3b2b02825d Source sweep: Replace std::ostringstream when used with a single append

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3726
2019-08-26 10:49:10 -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
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
dfb5936f0f Merge topic 'shared-string'
be7807478c cmDefinitions: Reduce allocation of keys and values in MakeClosure
e07e2bc8bb bootstrap: Compile cm::String
c1787cb5eb cpack.cxx: Re-order include blocks to follow our conventions
141e307484 cmConfigure.h: Tell windows.h not to define min/max macros

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3669
2019-08-21 11:57:05 -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
Brad King
be7807478c cmDefinitions: Reduce allocation of keys and values in MakeClosure
Use `cm::String` to store keys and values so that `MakeClosure` does
not need to allocate new copies of all of them.

Issue: #19581
2019-08-20 09:36:45 -04: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
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
Brad King
ad2b3a32d1 Genex: Optimize build setting TARGET_PROPERTY evaluation
For each build setting property (such as `COMPILE_DEFINITIONS` or
`INCLUDE_DIRECTORIES`), the value of `$<TARGET_PROPERTY:target,prop>`
includes the values of the corresponding `INTERFACE_*` usage requirement
property from the transitive closure of link libraries of the target.

Previously we computed this by constructing a generator expression
string like `$<TARGET_PROPERTY:lib,INTERFACE_COMPILE_DEFINITIONS>` and
recursively evaluating it with the generator expression engine.  Avoid
the string construction and parsing by using the dedicated evaluation
method `cmGeneratorTarget::EvaluateInterfaceProperty`.

Issue: #18964, #18965
2019-07-23 06:50:31 -04:00
Brad King
11fa818ecd Genex: Optimize usage requirement TARGET_PROPERTY recursion
In large projects the generation process spends a lot of time evaluating
usage requirements through transitive interface properties on targets.
This can be seen in a contrived example with deep dependencies:

    set(prev "")
    foreach(i RANGE 1 500)
      add_library(a${i} a.c)
      target_compile_definitions(a${i} PUBLIC A${i})
      target_link_libraries(a${i} PUBLIC ${prev})
      set(prev a${i})
    endforeach()

For each usage requirement (such as `INTERFACE_COMPILE_DEFINITIONS` or
`INTERFACE_INCLUDE_DIRECTORIES`), the value of the generator expression
`$<TARGET_PROPERTY:target,prop>` includes the values of the same
property from the transitive closure of link libraries of the target.

Previously we computed this by constructing a generator expression
string like `$<TARGET_PROPERTY:lib,INTERFACE_COMPILE_DEFINITIONS>` and
recursively evaluating it with the generator expression engine.  Avoid
the string construction and parsing by creating and using a dedicated
evaluation method `cmGeneratorTarget::EvaluateInterfaceProperty` that
looks up the properties directly.

Issue: #18964, #18965
2019-07-23 06:46:34 -04:00
Brad King
0239bf8ac8 Genex: In TARGET_PROPERTY check for usage reqs in link libs earlier 2019-07-21 08:17:04 -04:00
Brad King
7caebeb0e4 Genex: Re-order TARGET_PROPERTY logic to de-duplicate checks
Check for usage requirement properties early enough to avoid duplicate
checks in other conditions.
2019-07-21 08:14:27 -04:00
Brad King
b2785a0fbd Genex: Move TARGET_PROPERTY linked targets evaluation to end 2019-07-21 07:47:27 -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
Robert Maynard
808b818063 Genex: CompileLang and CompileLangAndId now match against a list of ids
This allows for expressions such as:

 $<COMPILE_LANG_AND_ID, CXX, GNU, Clang>
2019-06-03 10:20:23 -04:00
Robert Maynard
9fd602bfd3 Genex: PlatformId now can match against a list of ids. 2019-06-03 10:20:23 -04:00
Robert Maynard
ec66af2026 Genex: CompilerId now can match against a list of ids.
This allows for expressions like:
 $<$<CXX_COMPILER_ID:Clang,GNU>:-DMY_PRIVATE_DEFINE>
2019-06-03 10:20:23 -04:00
Brad King
5a1af142f1 Genex: Fix value lifetimes in nested TARGET_PROPERTY evaluation
For special properties like `INCLUDE_DIRECTORIES`, the pointer returned
by `cmTarget::GetProperty` is only valid until the next time the same
special property is queried on *any* target.  When evaluating a nested
`TARGET_PROPERTY` generator expression we may look up such a property
more than once on different targets.  Fix `TargetPropertyNode::Evaluate`
to store the lookup result in locally owned memory earlier.

Fixes: #19286
2019-05-22 10:19:41 -04:00
Robert Maynard
e214abdaab Genex: Add COMPILE_LANG_AND_ID generator expression 2019-05-14 14:54:15 -04:00
Brad King
323c4fb989 Merge topic 'genex-TARGET_FILE_BASE_NAME-manage-postfix'
6e5ccabe9b Genex: Update $<TARGET_FILE_BASE_NAME:...>: take care of POSTFIX
1f4c9aa7d2 Refactor: introduce method cmGeneratorTarget::GetFilePostfix

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3267
2019-05-03 11:42:47 -04:00
Brad King
e08efc36eb Merge topic 'genex-code-cleanup'
3d856eba16 cmGeneratorExpressionNode: refactor TargetPropertyNode
9e1df5df54 cmGeneratorExpressionNode: use ctor arguments instead of macro
36f36d6a49 cmGeneratorExpressionNode: add VersionNode
3f57787dff cmGeneratorExpressionNode: remove structs CompilerId*, CompilerVersion*
20d7c5631e cmGeneratorExpressionNode: add CharacterNode
abd62201bd cmGeneratorExpressionNode: simplify code in EqualNode
f2c8ff8259 cmGeneratorExpressionNode: Simplify static string constant

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3234
2019-05-02 09:43:09 -04:00
Marc Chevrier
6e5ccabe9b Genex: Update $<TARGET_FILE_BASE_NAME:...>: take care of POSTFIX
This capability complement MR !3190 and !3207
and is also needed to solve issue #18771.
2019-05-02 11:01:10 +02:00
Brad King
d0e6fc2833 Merge topic 'relax_TARGET_OBJECT_generator_expr'
ce078dda79 Relax the usage of TARGET_OBJECTS generator expression

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3178
2019-04-30 10:09:52 -04:00
Leonid Pospelov
3d856eba16 cmGeneratorExpressionNode: refactor TargetPropertyNode
Re-order logic to improve readability and de-duplicate conditions.
Factor out error message generation into a helper.
2019-04-22 10:44:31 -04:00
Leonid Pospelov
9e1df5df54 cmGeneratorExpressionNode: use ctor arguments instead of macro 2019-04-22 10:41:28 -04:00
Leonid Pospelov
36f36d6a49 cmGeneratorExpressionNode: add VersionNode 2019-04-22 10:41:28 -04:00
Leonid Pospelov
3f57787dff cmGeneratorExpressionNode: remove structs CompilerId*, CompilerVersion* 2019-04-22 10:41:28 -04:00
Leonid Pospelov
20d7c5631e cmGeneratorExpressionNode: add CharacterNode 2019-04-22 10:41:28 -04:00
Leonid Pospelov
abd62201bd cmGeneratorExpressionNode: simplify code in EqualNode 2019-04-22 10:41:28 -04:00
Brad King
f2c8ff8259 cmGeneratorExpressionNode: Simplify static string constant
Use our `""_s` user-defined literal to avoid initializing a static
std::string.
2019-04-22 10:41:10 -04:00
Robert Maynard
ce078dda79 Relax the usage of TARGET_OBJECTS generator expression
The geneator expression can now be used with static, shared, and
module libraries and executables.
2019-04-19 13:52:50 -04:00
Marc Chevrier
60ec292258 Genex: Rename $<TARGET_*_OUTPUT_NAME:...> in $<TARGET_*_FILE_BASE_NAME:...> 2019-04-15 18:22:14 +02:00
Marc Chevrier
b70bac647d Genex: add $<TARGET_FILE_PREFIX:...> and $<TARGET_FILE_SUFFIX:...>
These capabilities complement MR !3190
and is also needed to solve issue #18771.
2019-04-10 23:45:12 +02:00
Sebastian Lipponer
698f51abac Genex: Add $<FILTER:list,INCLUDE|EXCLUDE,regex> 2019-04-08 19:57:22 +02:00
Marc Chevrier
1889ed923e Genex: Add capability to retrieve base name for various target artifacts
This new capability is required to solve efficiently issue #18771
2019-04-08 07:49:08 -04:00
Marc Chevrier
26b6d2aff0 Refactor struct TargetFileSystemArtifact
Creates base class TargetArtifactBase which enable to share code with
future new functionalities.
2019-04-08 07:48:20 -04:00