1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-09 23:08:18 +08:00

91 Commits

Author SHA1 Message Date
friendlyanon
96a7040107 project: Define variables indicating whether project is top level
Define `PROJECT_IS_TOP_LEVEL` and `<PROJECT-NAME>_IS_TOP_LEVEL`.  The
latter is a STATIC cache entry just like other `<PROJECT-NAME>_*`
variables so that it is globally scoped.

Issue: #20310
Fixes: #21961
2021-03-26 09:35:34 -04:00
Asit Dhal
3c324689a7 include: refactor call sites of cmMakefile::ReadDependentFile
Fixes: #16773
2020-10-21 11:20:37 +02:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Vitaly Stakhovsky
f37c14e930 Source: use cmNonempty() 2020-07-28 08:31:31 -04:00
Vitaly Stakhovsky
36a5b3d1d1 cmMakefile::AddCacheDefinition: Add overload that accepts std::string value 2020-03-11 09:40:43 -04:00
Craig Scott
cdcc173e23 Merge topic 'project-version-buffer-overflow'
82cdb26c93 project: Fix potential buffer write-past-end for version components
15a0b0d046 Help: math() expressions must be representable as signed 64-bit

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3948
2019-10-28 06:50:22 -04:00
Craig Scott
82cdb26c93 project: Fix potential buffer write-past-end for version components
This fixes two errors: not accounting for the trailing null and a
misunderstanding of what std::numeric_limits::digits10 means.
2019-10-26 17:50:24 +11:00
Deniz Bahadir
f7acc1266c project: Add variable CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE
Follow up commit 0761186949 (project: Add variable
CMAKE_PROJECT_INCLUDE_BEFORE, 2019-03-28, v3.15.0-rc1~294^2) with a
project-specific variant.  This variable will be used similar to the
already existing `CMAKE_PROJECT_INCLUDE_BEFORE` and
`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` variables.

Fixes: #19854
2019-10-18 14:44:24 -04: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
Regina Pfeifer
77aa75b8dc cmProjectCommand: Port away from cmCommand 2019-09-21 05:13:30 +02: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
Brad King
de0a2354fc IWYU: Add missing cstddef includes for size_t and nullptr_t
The IWYU tool we use for CI now diagnoses these.
2019-09-03 11:46:52 -04: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
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
Sebastian Holtermann
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value
argument instead of a `const char *`.

Benefits are:
- `std::string` can be passed to `cmMakefile::AddDefinition` directly without
  the `c_str()` plus string length recomputation fallback.
- Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at
  compile time.

In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid
`std::string::c_str` calls and the `std::string` is passed directly.
Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might
be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
2019-07-24 11:11:25 +02:00
Alex Turbov
0ba5891ead project: Keep leading 0 in PROJECT_VERSION components
Introduce CMake policy `CMP0096` to make `project()` keep leading zeros
in version components.  As a side effect, it now allows really long
version numbers.

Fixes: #19421
Co-Author: Brad King <brad.king@kitware.com>
2019-07-16 07:48:40 -04:00
Alex Turbov
b1f387a7ea Refactor: Use raw string literals instead of escaping 2019-07-15 08:17:36 -04:00
Alex Turbov
41b85968d8 Refactor: Use initializer lists instead of push_back series 2019-07-15 08:17:36 -04:00
Alex Turbov
45e85dd2b2 Refactor: Add some const to vars 2019-07-15 08:17:36 -04:00
Alex Turbov
90f91e4d21 Refactor: Replace a "magic" number w/ a named constant 2019-07-15 08:17:36 -04:00
Alex Turbov
638383c38f Refactor: Eliminate one-time-used variables 2019-07-15 08:17:36 -04:00
Alex Turbov
9b6a53292f Refactor: Eliminate sep from the loop 2019-07-15 08:17:34 -04:00
Brad King
0dfb056cd3 Merge topic 'pr.projectbefore'
0761186949 project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3175
2019-04-04 11:32:41 -04:00
Artur Ryt
30bb14c657 Modernize: Enable modernize-raw-string-literal in clang-tidy 2019-04-02 19:59:54 +02:00
Ruslan Baratov
0761186949 project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE 2019-04-01 20:30:19 +03:00
Ruslan Baratov
dda0190458 project: Add variable CMAKE_PROJECT_INCLUDE 2019-03-27 22:39:02 +03:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -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
Craig Scott
f8a086a86b project(): Ensure DESCRIPTION and HOMEPAGE_URL variables are set
If a project() call does not have DESCRIPTION or HOMEPAGE_URL
options, it must still set the relevant variables or else those variables will
inherit values from an earlier project() call. That is inconsistent with how
VERSION is handled and is likely to be unexpected. The docs were also
ambiguous about what should happen in such cases.
2018-10-08 08:28:17 +11:00
Vitaly Stakhovsky
c8fd23ec6f cmMakefile: return directories as const std::string& 2018-08-27 14:07:43 -04:00
Brad King
6646771b0f project: Do not issue CMP0048 warnings on injected call
Fixes: #18202
2018-07-24 13:14:10 -04:00
Alex Turbov
af1c48871c CPack: Use project version as default for CPACK_PACKAGE_VERSION
* Introduce `CMAKE_PROJECT_VERSION` and the corresponsing components:
  `CMAKE_PROJECT_VERSION_MAJOR`, `CMAKE_PROJECT_VERSION_MINOR`,
  `CMAKE_PROJECT_VERSION_PATCH` and `CMAKE_PROJECT_VERSION_TWEAK`.

* `CPack` module use `CMAKE_PROJECT_VERSION_MAJOR`,
  `CMAKE_PROJECT_VERSION_MINOR` and `CMAKE_PROJECT_VERSION_PATCH`
  to initialize corresponsing CPack variables.
2018-05-03 08:26:03 +10:00
Alex Turbov
73f9b2974c project: Add HOMEPAGE_URL named parameter
This sets variables like PROJECT_HOMEPAGE_URL, which can be
used as default values for various things (packaging modules,
doxygen defaults, etc.). Some packaging modules have been
updated to do this as part of this commit.

Co-Author: Craig Scott <craig.scott@crascit.com>
2018-03-17 08:25:48 +11:00
Craig Scott
fd28c382b4 project: Add <PROJECT-NAME>_DESCRIPTION
For consistency with the VERSION keyword, also define the
<PROJECT-NAME>_DESCRIPTION variable.
2018-03-17 08:25:48 +11:00
Alex Turbov
587bad7ba2 project: warn on metadata arguments missing values
Warn if `DESCRIPTION` or `VERSION` is given without a following value.
2018-03-07 09:35:59 -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
Pavel Solodovnikov
86dc86dd6c Add const-reference qualifications 2017-05-26 19:50:11 +03:00
Brad King
2cb98329f1 Merge topic 'project-description'
3b484871 project: Add `DESCRIPTION` parameter

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !679
2017-04-13 08:14:23 -04:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
Automate with:

git grep -l '#include <cm_' -- Source \
  | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g'

git grep -l '#include <cmsys/' -- Source \
  | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g'

git grep -l '#include <cm[A-Z]' -- Source \
  | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
2017-04-11 22:35:21 +02:00
Alex Turbov
3b4848717a project: Add DESCRIPTION parameter
It is quite often the project description has used in a real world software.
Examples include:

* part of a help screen of the application
* builtin resources (`*.rc` files, data for "About" dialog of a GUI app, & etc)
* most generators for CPack can use it
* it could be used by documentary software (Doxygen, Sphinx) which is usually
  integrated to CMake based projects via `add_custom_target()`

Now `project()` call learned an optional `DESCRIPTION` parameter with a
short string describing a project. Being specified, it would set the
`PROJECT_DESCRIPTION` variable which could be used in `configure_file()`
or whatever user wants.  Also `PROJECT_DESCRIPTION` is a default value
for `CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
2017-04-11 10:17:00 -04: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
Stephen Kelly
2fe3e55d53 cmState: Move CacheEntryType enum to separate namespace
Port dependent code to the change.
2016-10-19 15:40:58 +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
73f648f167 use empty method to check for emptyness 2016-09-15 23:59:29 +02: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
Stephen Kelly
6ce940ac97 cmMakefile: Use std::string in ProjectName API. 2015-08-25 19:55:34 +02:00
Stephen Kelly
8bfaadfa39 cmMakefile: Move IsRoot API from cmLocalGenerator. 2015-06-21 21:14:05 +02:00
Stephen Kelly
821a711b6f project(): Remove unused variable. 2015-06-09 23:42:13 +02:00