1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-13 22:30:25 +08:00

152 Commits

Author SHA1 Message Date
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
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
Sebastian Lipponer
abbb8a7b1d Genex: Add $<REMOVE_DUPLICATES:list> 2019-04-01 21:52:17 +02:00
Brad King
7b81b1c72c Merge topic 'cuda_compiler_generator_expressions'
b53766b205 CUDA: Support compiler id and version generator expressions
b544e34af6 All VersionNode use the same capitalization pattern

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3085
2019-03-13 10:16:25 -04:00
Robert Maynard
b53766b205 CUDA: Support compiler id and version generator expressions
Introduce the CUDA_COMPILER_ID and CUDA_COMPILER_VERSION generator
expressions.
2019-03-11 12:33:43 -04:00
Robert Maynard
b544e34af6 All VersionNode use the same capitalization pattern 2019-03-11 11:48:37 -04:00
Henri Manson
463c2fba4e Genex: Teach SHELL_PATH to support a list of paths
Extend the genex added by commit ca6ba3fee5 (Genex: Add a SHELL_PATH
expression, 2015-09-24, v3.4.0-rc1~37^2) to accept a `;`-list of paths,
convert them all, and generate a list separated by the native shell
`PATH``` separator.
2019-03-11 11:39:25 -04:00
Sebastian Holtermann
a490ea4a28 cmGeneratorExpressionNode: Initialize node key map in class constructor
By initializing the node map in the class constructor of the static instance
we avoid an if-empty check.
2019-02-27 13:25:22 +01:00
Brad King
122946def9 Merge topic 'genex-GENEX_EVAL-fix-recursion'
e429e9af42 genex: Fix erroneous handling of recursion for $<GENEX_EVAL:>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: yrHeTaTeJlb <jjj.bo@yandex.ru>
Merge-request: !2954
2019-02-13 08:40:04 -05:00
Marc Chevrier
e429e9af42 genex: Fix erroneous handling of recursion for $<GENEX_EVAL:>
Fixes: #18894
2019-02-13 08:37:02 -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
Artur Ryt
f3534386b5 Prefer front/back/data over dereferencing begin/rbegin iter
Changed for sequenced containers: vector, list, string and array
2019-02-06 10:43:16 -05:00
Regina Pfeifer
3f9822ff6d clang-tidy: Silence use-equals-default warning
clang-tidy 7 has an option to suppress this warning in macros which
defaults to '1'.  Set the option to '0' and silence the warning
explicitly.
2019-01-30 17:51:07 +01:00
Regina Pfeifer
55671b41d2 clang-tidy: Use = default
Suppress some cases in `Source/cmGeneratorExpressionNode.cxx` and
`Source/cmUVHandlePtr.h` where a few older compilers require a
user-defined default constructor (with `{}`).
2019-01-25 06:44:32 -05:00
Andrew Paprocki
a080914274 Fortran: Add compiler ID/Version generator expressions
Adds `Fortran_COMPILER_ID` and `Fortran_COMPILER_VERSION` generator
expression support to match equivalent `C_COMPILER_ID`,
`CXX_COMPILER_ID`, `C_COMPILER_VERSION`, and `CXX_COMPILER_VERSION`
support.

This is very helpful in the case where the C/C++ compiler suite is a
different type of compiler from the platform Fortran compiler and
projects use generator expressions to assign compiler flags and
definitions.  (e.g. `GNU` C/C++ and `SunPro` Fortran on Linux)
2019-01-18 08:56:13 -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
Regina Pfeifer
414aa6c81e clang-tidy: Simplify boolean expressions 2019-01-15 11:40:25 -05:00
Kyle Edwards
b5f8113ca7 Genex: Add policy to handle empty list items in $<IN_LIST:...>
The old behavior of $<IN_LIST:...> is inconsistent with that of
if(IN_LIST), in that it does not find an empty search item even if
the list contains empty items. This change adds a new policy to
correctly handle empty items and make the behavior more consistent
with if(IN_LIST).

Fixes: #18556
2018-11-19 17:02:06 -05:00