1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-12 00:40:45 +08:00

146 Commits

Author SHA1 Message Date
Deniz Bahadir
071f0d6f98 CMP0163: Make GENERATED source file property globally visible
This was originally attempted by policy CMP0118, but its
implementation did not cover all intended use cases.  We fixed its
documentation in commit 1dabbbb5e0 (CMP0118: Revise documentation to
describe actual behavior, 2024-03-20).

Add new policy CMP0163 to cover the remaining use cases.  In particular,
make the `GENERATED` property visible to `get_property` calls in other
directories.  In order to capture the original intention of CMP0118,
define CMP0163's NEW behavior to also imply CMP0118's NEW behavior.

Fixes: #25437
Fixes: #25058
2024-03-29 08:54:11 -04:00
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Marc Chevrier
45f17e5a85 cmList: Add container conversion to string 2023-06-22 15:44:17 +02:00
Marc Chevrier
aa5fed5052 SetProperty: suppress raw pointer usage 2023-05-26 14:48:22 +02:00
Ben Boeckel
7e3f9aa1b2 target_sources: give a hint when a file named FILE_SET is not found
`FILE_SET` is only supported within `target_sources()` and only directly
after a visibility keyword or another `FILE_SET`. Give a hint as to what
might be wrong if a file named `FILE_SET` cannot be found for any
reason.

Fixes: #24539
2023-02-24 17:43:22 -05:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Marc Chevrier
6dfa581bab Enhancement: SetProperty accept cmProp or std::string
Methods SetProperty of classes cmPropertyMap, cmStateDirectory
and cmMakefile accept now cmProp or std::string as argument.
2021-08-25 10:09:02 +02:00
Marc Chevrier
e5cd39ca80 cmProp: refactoring: transform alias in class
To handle safely the values used by CMake variables and properties,
introduce the class cmProp as a replacement from the simple pointer
to std::string instance.
2021-08-08 16:19:08 +02:00
Brad King
06feb845aa CMP0118: Fix NEW behavior when looking up target sources
Under the CMP0118 NEW behavior, sources generated in one directory
should be visible when added to targets in other directories.  This was
accidentally left out of commit 6624b65b3f (GENERATED prop: Add
implementation for policy CMP0118 being set to NEW, 2020-11-09,
v3.20.0-rc1~393^2~1).

Fixes: #18399
2021-03-18 09:57:49 -04:00
Ben Boeckel
cdfc4e3195 clang-tidy: fix readability-qualified-auto warnings 2021-01-27 08:45:45 -05:00
Deniz Bahadir
6624b65b3f GENERATED prop: Add implementation for policy CMP0118 being set to NEW
* Adding implementation for policy CMP0118 being set to `NEW`.
* Adding new tests for policy CMP0118 being set to `NEW`.
* Checking the `GENERATED` property with `get_source_file_property` or
  `get_property` now always returns exactly `1` or `0`. No other values
  will be returned. Note, that this is a backwards-incompatible change,
  even when policy CMP0118 is unset or set to `OLD`.
* Additionally, as `get_source_file_property` and `get_property` now
  always check if a source-file was marked globally visible, even when
  CMP0118 is unset or set to `OLD`, they possibly return `1` where they
  might have returned `0` before the changes introduced by this commit.
  Note, that this is a backwards-incompatible change, even when policy
  CMP0118 is unset or set to `OLD`.
* As a consequence, the tests for policy CMP0118 being unset or set to
  `OLD` got slightly adjusted, too, to reflect these changes in
  behavior.
2020-11-24 18:16:51 +01:00
Deniz Bahadir
b14fe704f8 GENERATED prop: Simplify determining the language of a source file
This simplification will help the later following structural changes of
class `cmSourceFile`.
2020-11-24 17:55:01 +01:00
Vitaly Stakhovsky
c7b50349de cmSourceFile::GetPropertyForUser: return cmProp
also fix GetSafeProperty() return type
2020-11-04 10:11:54 -05:00
Kyle Edwards
fd50a75fa0 CMP0115: Require source file extensions to be explicit 2020-10-13 09:46:54 -04:00
Vitaly Stakhovsky
7156911242 cmIsOn: add overload accepting const std::string* 2020-07-14 08:22:24 -04:00
Robert Maynard
7628153edb Refactor file extension queries to be more consistent
It was very easy to forgot to check against all language file
extensions. This updates the internal API to have a unified API.
2020-06-22 09:13:16 -04:00
Vitaly Stakhovsky
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp 2020-04-14 10:57:17 -04:00
Vitaly Stakhovsky
aba23c747b cmMakefile::GetProperty: return cmProp 2020-04-01 10:56:34 -04:00
Vitaly Stakhovsky
60f57d0dcc cmPropertyMap: Introduce cmProp as return type for GetProperty() functions
Currently properties are usually stored internally as `std::string`.
However, family of GetProperty() functions return them as `const char *` using `c_str()`.
The proposed `cmProp`, typedef'ed as `const std::string *` will expose properties
more naturally.
2020-03-13 13:32:17 -04:00
Vitaly Stakhovsky
1398517f31 AppendProperty: convert value param to std::string 2020-01-25 10:37:00 -05:00
Tim Blechmann
5da3d01fd1 cmSourceFile: avoid unnnecessary copies
the copies in `cmSourceFile::FindFullPath` are one of the hotspots of
my build system: we can easily avoid them by capturing by reference
instead of by value
2020-01-16 12:22:25 +08:00
Justin Goshi
c71ac889ba cmSourceFile: Add backtraces for a few source properties
Adding backtrace support for INCLUDE_DIRECTORIES, COMPILE_OPTIONS, and
COMPILE_DEFINITIONS.
2019-09-26 10:56:52 -04:00
Daniel Eiband
8456f60dbc cmSourceFile: Remove non-const GetProperties accessor
Manipulating the property map of cmSourceFile directly may invalidate the class
invariant of the cached value IsGenerated.  Provide the setter SetProperties
which also updates IsGenerated.
2019-09-21 13:31:36 +02:00
Tushar Maheshwari
8c83f39a90 cmSourceFile: use unique_ptr for CustomCommand 2019-09-14 00:54:31 +05:30
Daniel Eiband
2d888e3390 cmSourceFile: Rename mutating GetFullPath() overload
Rename mutating GetFullPath() overload to ResolveFullPath().
2019-08-29 22:51:58 +02:00
Tushar Maheshwari
a40744c81a cmSourceFile: Move LANGUAGE to GetPropertyForUser
- Remove the special case from cmGetSourceFilePropertyCommand

Tests: check LANGUAGE for source file
- use target_sources to add file
- use get_property to read property value
2019-08-27 21:41:12 +05:30
Tushar Maheshwari
8cb3cffa42 cmSourceFile: Rename non-const GetLanguage
GetOrDetermineLanguage:
- Read the property if available
- Determine the Language using the file extension

Fix all usage of the non-const member in the repository.
2019-08-27 21:35:42 +05:30
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
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
254b7260f4 cmSourceFile: Check if a file is GENERATED first in the full path computation
In `cmSourceFile::FindFullPath` check first if the file is GENERATED before
aborting on `FindFullPathFailed`.  This allows recomputation of the full path
when the GENERATED property was set after the file path was computed with an
error.
2019-02-02 18:39:22 +01:00
Sebastian Holtermann
cd8a930d61 cmSourceFile: Refactor FindFullPath method
Refactors the cmSourceFile::FindFullPath method to
use lambdas.
2019-02-02 18:39:22 +01:00
Sebastian Holtermann
6d407ae439 Use cmSourceFile::GetIsGenerated 2019-02-01 17:02:53 +01:00
Sebastian Holtermann
2ddf3f4467 cmSourceFile: Add IsGenerated method
All cmSourceFiles are checked at least once whether they're `GENERATED` or not.
This adds a convenience method `GetIsGenerated` that returns a private
boolean cache variable `IsGenerated`.  `IsGenerated` is updated every time the
`GENERATED` property is written.
2019-02-01 16:55:35 +01:00
Sebastian Holtermann
b9d44fc350 cmSourceFile: Additional static property strings 2019-02-01 16:21:32 +01: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
Vitaly Stakhovsky
c8fd23ec6f cmMakefile: return directories as const std::string& 2018-08-27 14:07:43 -04:00
Sebastian Holtermann
127094f2f0 Add GetSafeProperty method to cmTarget, cmGeneratorTarget and cmSourceFile 2018-07-02 12:39:54 +02: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
Ben Boeckel
b0716fbcc5 cmSourceFileLocation: allow skipping ambiguous extensions
The ambiguous extension logic is an old behavior that ends up taking
lots of extra compute cycles to execute. This is triggered by various
CMake codepaths which pass extension-less paths down when CMake actually
knows that they are not ambiguous. These codepaths will be indicated in
upcoming changes.

Various APIs have gained a cmSourceFileLocationKind parameter, but they
are all optional and default to the existing behavior.
2018-01-10 11:21:11 -05:00
Luz Paz
3ab7bf8285 Various typo fixes
Some are user-facing. Others are source comments.
2018-01-04 06:52:01 +11:00
Pavel Solodovnikov
7d5095796a Meta: modernize old-fashioned loops to range-based for.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-12 16:22:47 +03:00
Sebastian Holtermann
687aef913c cmSourceFile: Avoid unnecessary vector copy 2017-08-26 14:45:46 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Sebastian Holtermann
8e452e67e9 Remove AUTOGEN variables from cmSourceFile and cmMakefile 2017-08-22 19:10:32 +02:00
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Stephen Kelly
e6eecec761 cmListFileCache: Remove cmState header include
Include it in dependents which have previously relied on it
transitively.
2016-10-19 15:41:00 +02:00
Stephen Kelly
a91eaf3872 cmState: Port dependents to new cmStateTypes header 2016-10-19 15:40:59 +02:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Daniel Pfeifer
efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -04:00
Daniel Pfeifer
7b6349da4d CMake: don't use else after return 2016-08-18 20:36:29 +02:00