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

129 Commits

Author SHA1 Message Date
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
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
Marc Chevrier
023188ffb4 INTERFACE_POSITION_INDEPENDENT_CODE: add generator expressions support
Fixes: #16532
2018-11-08 14:58:57 +01:00
Brad King
a8f628c0a4 Merge topic 'getsafedef-stdstring'
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const&

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2350
2018-09-18 11:18:00 -04:00
Vitaly Stakhovsky
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& 2018-09-18 11:16:46 -04:00
Brad King
2f708f5d65 Make internal TARGET_PROPERTY generator expressions more robust
While collecting usage requirements from the `INTERFACE_*` properties of
directly linked targets, we internally generate `TARGET_PROPERTY:` and
`TARGET_OBJECTS:` generator expressions to refer to those properties on
those targets.  At the point we generate these expressions we already
have a pointer to an exact `cmGeneratorTarget` instance.

Switch from using the target name in these generator expressions to
using an internal unique name generated for each `cmGeneratorTarget`
instance to be referenced.  This avoids depending on the user-facing
target name to find the same target we already have.
2018-09-12 12:46:25 -04:00
Brad King
f35be59961 Fix transitive usage requirements through same-name imported targets
If two imported targets in different directories have the same name we
should still be able to propagate transitive usage requirements from
both.  Fix the DAG checker to work with target pointers instead of
target names since the pointers will not be duplicated even if the names
are.

Fixes: #18345
2018-09-10 07:51:44 -04:00
Vitaly Stakhovsky
6f16be6a62 Remove unnecessary c_str() calls
Use the new IsOn(),IsOff() overloads.
2018-09-05 15:12:57 -04:00
Vitaly Stakhovsky
69ca85cc7f Remove unnecessary c_str() in RegularExpression::find calls 2018-08-07 15:28:24 -04:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Henry Schreiner
4f82199bef Genex: Allow COMPILE_LANGUAGE to name a language that is not loaded
Evaluate to false on `$<COMPILE_LANGUAGE:Lang>` if language `Lang`
is not loaded.  This is helpful in exported targets consumed in other
projects that may not enable all the same languages.

Fixes: #17952
2018-05-03 08:34:39 -04:00
Marc Chevrier
4d15046edd Genex: Add $<TARGET_GENEX_EVAL:...> and $<GENEX_EVAL:...>
Fixes: #17884
2018-04-23 11:13:52 +02:00
Michael Stürmer
fb433ff283 cmGeneratorTarget: Make import library checks config-aware 2018-04-05 06:36:49 +02:00
Alex Turbov
7b173a2933 genex: Add TARGET_NAME_IF_EXISTS expression
Define `$<TARGET_NAME_IF_EXISTS:tgt>` to mean `tgt` if the target
exists and otherwise an empty string.
2018-03-28 08:38:00 -04:00
Alex Turbov
7fec336bf7 genex: Add TARGET_EXISTS to check for target existence
Define `$<TARGET_EXISTS:a>` to `1` if `a` is an existed target name,
else `0`.
2018-03-09 08:24:05 -05:00
Marc Chevrier
5089f560e7 Genex: Add IN_LIST logical operator
Implements #17679
2018-02-07 10:57:18 +01:00
Brad King
f8ca0ab3ac Merge topic 'std-string-apis'
653b8946 Reduce raw string pointers usage.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1729
2018-02-01 08:05:33 -05:00
Ben Boeckel
6dfd0f9294 cmGeneratorExpressionNode: avoid some strlen in $<TARGET_PROPERTY> 2018-01-31 11:04:35 -05:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Brad King
506fda1cf0 Genex: Enable COMPILE_LANGUAGE for INCLUDE_DIRECTORIES with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language.  By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags.  Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`INCLUDE_DIRECTORIES` to match the selected language.

This is not exactly the same as for other generators, but is the best VS
and Xcode can do.  It is also sufficient for many use cases since the
set of include directories for C and C++ is frequently similar but may
be distinct from those for other languages like CUDA.

Fixes: #17435
2018-01-12 14:27:37 -05:00
Brad King
c2f79c9867 Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language.  By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags.  Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`COMPILE_DEFINITIONS` to match the selected language.

This is not exactly the same as for other generators, but is the best VS
and Xcode can do.  It is also sufficient for many use cases since the
set of definitions for C and C++ is frequently similar but may be
distinct from those for other languages like CUDA.

Issue: #17435
2018-01-12 14:27:37 -05:00
Brad King
2ae880fa8f Genex: Enable COMPILE_LANGUAGE for COMPILE_OPTIONS with Visual Studio
Since commit v3.9.0-rc4~3^2~1 (VS: Fix target_compile_options for CUDA,
2017-06-21), the evaluation of `COMPILE_LANGUAGE` receives the proper
language.  The set of compile flags used for a target's C and C++
sources is based on the linker language.  By default this is always the
C++ flags if any C++ sources appear in the target, and otherwise the C
flags.  Therefore we can define the `COMPILE_LANGUAGE` generator
expression in `COMPILE_OPTIONS` to match the selected language.

This is not exactly the same as for other generators, but is the best VS
can do.  It is also sufficient for many use cases since the set of
allowed flags for C and C++ is almost the same in Visual Studio.
Furthermore, since the VS generator moves many of the flags to
declarative `.vcxproj` elements, it will automatically avoid passing
C++ flags for C sources.

Issue: #17435
2017-11-20 13:51:25 -05:00
Brad King
2b7d59f310 Genex: Enable COMPILE_LANGUAGE for file(GENERATE) with Visual Studio
Issue: #17435
2017-11-17 14:31:07 -05:00
Brad King
0f6f7c8ab1 Genex: Fix COMPILE_LANGUAGE messages to allow file(GENERATE) with Xcode
When rejecting the `COMPILE_LANGUAGE` generator expression on include
directories and compile definitions with Xcode, add `file(GENERATE)` to
the allowed set in the message.  It is allowed and already covered
by the `RunCMake.File_Generate` test `COMPILE_LANGUAGE-genex` case.
2017-11-17 11:56:00 -05:00
Matthias Maennich
57132765e0 Replace cmArray{Begin,End,Size} by their standard counterparts
std::{begin,end} are part of C++11, std::{cbegin,cend} are part of C++14
and an standard compliant implementation has been introduced within the
'cm' namespace: cm::{cbegin,cend}.

std::size is only part of C++17, hence exposing a compliant implementation
within namespace cm (cm::size).

where possible, the standard implementations are reused.
2017-10-23 17:51:35 +02:00