Commit Graph

76 Commits

Author SHA1 Message Date
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* 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.

Issue: #26123
2025-01-23 13:09:50 -05:00
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
Deniz Bahadir
00c6573d86 cmSetPropertyCommand: Refactor checks for CMP0118 2024-03-28 14:16:10 +01:00
Vitaly Stakhovsky
822203dd65 Source: Rename SetProperty(nullptr_t) to RemoveProperty()
Avoid assignment to NULL semantics.
2023-08-15 12:13:56 -04:00
Kyle Edwards
753999d4db set_property(TEST): Add DIRECTORY option 2023-08-10 17:36:14 -04:00
Kitware Robot
33abef7416 Revise C++ coding style using clang-format-15
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 15.

* 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.

Fixes: #24315
2023-01-18 16:20:47 -05:00
Brad King
52c95540b7 target_*: Fix cross-directory call backtraces
Record the call-site backtrace, not the current backtrace of the
target's directory.

Fixes: #23873
2022-08-22 15:29:43 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Marc Chevrier
dc3aa4024e Refactor: Use new SetProperty signatures 2021-08-25 10:09:10 +02:00
Ben Boeckel
cdfc4e3195 clang-tidy: fix readability-qualified-auto warnings 2021-01-27 08:45:45 -05:00
Ben Boeckel
4f396e6528 clang-tidy: fix performance-no-automatic-move warnings 2021-01-27 08:45:44 -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
ca4ce458a3 GENERATED prop: Check CMP0118 policy and warn in certain situations
* Adding tests for CMP0118 being unset (aka set to `WARN`).
* Adjusting the (unrelated) RunCMake.CMP0026 test to set CMP0118 to
  `NEW`,
* Adjusting the (unrelated) RunCMake.Ninja test to set CMP0118 to `OLD`.
* Adjusting the (unrelated) RunCMake.FileAPI test to set CMP0118 to
  `OLD`.

Note:
Setting CMP0118 to `NEW` and modifying the `GENERATED` property with
`set_property` or `set_source_files_properties` will currently NOT set
that property because the implementation is still to come.
2020-11-24 17:54:54 +01:00
Deniz Bahadir
75cb8615e9 Fix typo in function name 2020-11-17 20:28:02 +01:00
Brad King
f2daa025e3 {get,set}_property: Add support for referencing binary directories
Index directories by their binary directory path in addition to their
source directory path.

Fixes: #19262
2020-09-23 09:25:42 -04:00
Alexandru Croitor
f6969b917d set_property: Deduplicate source file directory scopes
A user could specify the same directory scope to set_property()
multiple times, which in conjunction with APPEND would append the
property multiple times.

Make sure to deduplicate scopes across both DIRECTORY and
TARGET_DIRECTORY options, so that a property is only appended
once in such a scenario.

Fixes: #20941
2020-07-13 17:43:17 +02:00
Alexandru Croitor
1235f2d747 set_property: Allow both DIRECTORY and TARGET_DIRECTORY together
Allow to specify both DIRECTORY and TARGET_DIRECTORY at the same time in
`set_source_files_properties()` and `set_property(SOURCE)` commands.

Add test cases and update the documentation.

Fixes: #20932
2020-07-09 06:33:52 -04:00
Alexandru Croitor
177052d6b8 set_property: Fix name of TARGET_DIRECTORY option in error messages 2020-07-09 06:33:03 -04:00
Alexandru Croitor
3d4b70ea64 set_source_files_properties: Allow specification of directory scope
Both set_source_files_properties() and set_property(SOURCE) now accept
two new optional arguments: DIRECTORY and TARGET_DIRECTORY.

The DIRECTORY option takes a list of relative or absolute paths
pointing to processed source directories (add_subdirectory was
already called on them).

These paths specify directory scopes where the source file properties
will be set. Previously the scope was always the currently processed
source directory.

Similarly TARGET_DIRECTORY takes a list of targets, whose source
directories will be used as the list of scopes where to set the
source file properties.

get_property() and get_source_file_property() also get the same
new arguments, except only one value can be specified instead
of a list.

Fixes: #20128
2020-05-14 16:31:22 +02:00
Brad King
25f48761fa Simplify absolute path conversions using CollapseFullPath full signature 2020-03-24 10:10:06 -04:00
Vitaly Stakhovsky
bd89133543 cmState::GetCacheEntryValue: return cmProp 2020-03-17 12:09:20 -04:00
Vitaly Stakhovsky
a6cd48ac41 Source: use std::string overloads 2020-03-10 10:55:09 -04:00
Vitaly Stakhovsky
1398517f31 AppendProperty: convert value param to std::string 2020-01-25 10:37:00 -05:00
Asit Dhal
9dba84cfa5 Refactor: Use cmStrCat to construct error strings
Replace string construction using std::stringstream with cmStrCat and
cmWrap.
2019-09-18 14:18:46 -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
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
Gabor Bencze
36f32d3604 cmCommand refactor: cmSetPropertyCommand 2019-08-20 14:42:20 -04: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
Artur Ryt
30bb14c657 Modernize: Enable modernize-raw-string-literal in clang-tidy 2019-04-02 19:59:54 +02:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -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
Vitaly Stakhovsky
6f16be6a62 Remove unnecessary c_str() calls
Use the new IsOn(),IsOff() overloads.
2018-09-05 15:12:57 -04: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
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
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Pavel Solodovnikov
86dc86dd6c Add const-reference qualifications 2017-05-26 19:50:11 +03:00
Daniel Pfeifer
602b78aa79 Remove redundant c_str() calls 2016-10-30 18:34:06 +01:00
Daniel Pfeifer
e81c323da9 Include necessary headers in commands 2016-10-26 09:02:44 +02:00
Daniel Pfeifer
608afd4f62 Separate compilation for commands included in cmBootstrapCommands2 2016-10-21 18:14:51 +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
1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* 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.
2016-05-16 16:05:19 -04:00
Brad King
0ac18d40c8 Remove //------... horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King
e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King
180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Stephen Kelly
5f66900e71 cmGlobalGenerator: Port Find API to cmMakefile. 2015-08-07 04:10:29 +02:00
Stephen Kelly
a0836ed978 Port to cmMakefile::GetGlobalGenerator. 2015-05-03 11:42:00 +02:00
Stephen Kelly
55d80d0a85 cmMakefile: Rename GetCurrent{,Source}Directory.
Match the names used in cmake code.
2015-04-21 00:12:52 +02:00
Stephen Kelly
f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00