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

56 Commits

Author SHA1 Message Date
Brad King
d9d9326e14 Source: Avoid out-of-range inputs to std::isspace()
`isspace` takes `int` but documents that the value must be representable
by `unsigned char`, or be EOF.  Use a wrapper to cast to `unsigned char`
to avoid sign extension while converting to `int`.  This generalizes the
fix from commit 5e8c176e2a (cmExecuteProcessCommand: Cast c to unsigned
char before cast to int, 2024-01-05) to other `isspace` call sites.

This was detected by assertions in the MSVC standard library while
processing UTF-8 text.

Issue: #25561
2024-01-17 10:17:06 -05:00
Matthew Woehlke
302f5171d8 Utilities/Sphinx: Add 'cref' role
Add a role that can be used to create local links (a la '`LINK`_'), but
that also applies literal style. This is particularly useful for
referring to subcommands within the command's documentation in a style
that is consistent with ':command:`BAR <foo(BAR)>`' but is much less
verbose.

Although this is intended for subcommands, it works with any local
reference.

Co-authored-by: Brad King <brad.king@kitware.com>
2023-03-14 15:20:47 -04:00
Brad King
8c52458a9e cmRST: Fix cmake domain directives with newline before argument
The `signature` directive added by commit 74e3c1d313 (Utilities/Sphinx:
Add a directive to document command signatures, 2023-02-24) will be
commonly used with the form:

    .. signature::
       some_command(SOME_SIGNATURE)

      Docs for this signature.

Drop the assumption that all CMake domain directives are immediately
followed by their argument on the same line.
2023-03-09 16:10:03 -05:00
Brad King
d4b21bcdd6 cmRST: Fix typo in comment 2023-03-09 16:10:03 -05:00
Brad King
6a84717d17 cmRST: Convert enum types to enum class
This improves readability and avoids unintended conversions.
2023-03-09 16:09:48 -05:00
Matthew Woehlke
74e3c1d313 Utilities/Sphinx: Add a directive to document command signatures
Add a `signature` directive to offer a CMake version of Sphinx's
`function` directive, similar to that found in other domains (py, cpp,
etc.).  Like others, this takes one or more signatures as arguments and
creates dt/dd nodes from the signatures and the directive contents.
2023-03-03 17:05:02 -05:00
Ben Boeckel
a5f8cbe8b1 clang-tidy: address modernize-use-default-member-init lints 2022-05-24 09:09:43 -04:00
Ben Boeckel
054754359a cmRST: support versionadded and versionchanged directives
This makes `versionadded` and `versionchanged` directives show up in
`cmake --help-*` output instead of disappearing (and potentially making
empty sections).

Fixes: #22808
2021-10-27 09:15:00 -04:00
Brad King
7d498d6b43 Utilities/Sphinx: Add role and directive for 'genex' in CMake domain
This enables cross-reference syntax for CMake generator expressions:

    :genex:`SOME_GENEX`
    :genex:`$<SOME_GENEX>`
    :genex:`$<SOME_GENEX:...>`

and definition of CMake generator expressions via a directive:

    .. genex:: SOME_GENEX
    .. genex:: $<SOME_GENEX>
    .. genex:: $<SOME_GENEX:...>

It also adds generator expressions defined by the directive and by
`Help/genex/SOME_GENEX.rst` documents to the index.
2021-01-18 12:35:41 -05:00
Brad King
621ba5e1f2 cmRST: Add support for 'envvar' directive
This was accidentally left out of commit 8acf46caf1 (Utilities/Sphinx:
Add role and directive for 'envvar' in CMake domain, 2018-04-19,
v3.12.0-rc1~200^2~1).
2021-01-18 12:35:40 -05:00
Ben Boeckel
f2a33107be clang-tidy: address bugprone-branch-clone lints
Arguably, many of these are bugs in `clang-tidy`. An if/else tree with
other conditionals between cloned blocks may be relying on the
intermediate logic to fall out of the case and inverting this logic may
be non-trivial.

See: https://bugs.llvm.org/show_bug.cgi?id=44165
2020-04-13 11:26:02 -04:00
Rolf Eike Beer
ef778d77e0 replace std::string::substr() with operations that do not allocate memory
Modify the original string instead of creating a new copy with substr() when it
is not used for anything else afterwards.
2020-03-23 22:41:44 +01:00
Rolf Eike Beer
bfb69f9543 replace "substr(0, xx) ==" with cmHasPrefix() 2020-03-23 20:19:26 +01: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
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -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
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
a9b38a1757 cmRST: Fix crash on empty markup block 2019-04-05 08:18:14 -04: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
Regina Pfeifer
5a0784ddea clang-tidy: Pass by value 2019-01-22 13:03:04 -05:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Regina Pfeifer
3e60580784 clang-tidy: Fix readability-static-accessed-through-instance
Enable the check in .clang-tidy and fix all warnings.
2018-11-22 00:11:37 +01:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Kyle Edwards
2a2829cc75 Help: Add new section for CPack generators
The documentation for CPack generators previously lived in their
respective internal CMake modules. This setup was misleading,
because it implied that you should include the modules in your own
code, which is not the case. Moving the documentation into a
separate section does a better job of hiding the internal modules,
which are just an implementation detail. The generator documentation
has also been modified to remove any references to the module name.

The CPackIFW module is a special exception: since it has user-facing
macros, the documentation for these macros has been kept in the module
page, while all other documentation related to the IFW generator has
been moved into the new section.

To make it easier to find the new documentation, the old help pages
for the CPack*.cmake modules have not been deleted, but have been
replaced with a link to their respective help page in the new
documentation section.
2018-06-21 11:00:25 -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
Brad King
7d918b3cee cmRST: Parse inline links and inline literals
Render links as the link text only.  Render literals as themselves.
This is closer to what the Sphinx text generator does.
2018-05-07 10:10:37 -04:00
Brad King
828e18bb3e cmRST: Add support for 'envvar' cmake domain role
This was accidentally left out of commit 8acf46caf1 (Utilities/Sphinx:
Add role and directive for 'envvar' in CMake domain, 2018-04-19).
2018-05-04 07:52:14 -04:00
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +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
Pavel Solodovnikov
db2d46e2dd Remove second arg: npos in substr usages 2017-06-01 14:19:52 -04:00
Pavel Solodovnikov
8b6f439ef2 Access string npos without instance 2017-06-01 14:19:51 -04:00
Daniel Pfeifer
b26577c92a clang-tidy: remove else after break and continue 2017-04-21 10:44:07 +02: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
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
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
de37065661 cmRST: Parse toctree lines with Sphinx cross-reference syntax 2016-05-02 15:16:07 -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
Stephen Kelly
bb9d71b4fe Replace loops with algorithms. 2015-02-20 21:36:58 +01:00
Stephen Kelly
8c74a41ff3 cmRST: Replace two erase with a rotate and larger erase. 2015-02-20 21:36:58 +01:00
Stephen Kelly
8ed6ecac3f cmRST: Move two algorithms beside each other. 2015-02-20 21:36:58 +01:00
Stephen Kelly
dfe49c2056 cmRST: Use std::min where appropriate. 2015-02-20 21:36:58 +01:00
Stephen Kelly
ac26d4b343 Split cmAlgorithms into a separate header file. 2015-02-10 22:14:18 +01:00
Stephen Kelly
55a73e6b1f Use the cmJoin algorithm where possible. 2015-01-08 22:28:18 +01:00
Nils Gladitz
15a8af21e8 Add an "installed file" property scope
Teach set_property and get_property an "INSTALL" property type to be
associated with install-tree file paths.  Make the properties available
to CPack for use during packaging.  Add a "prop_inst" Sphinx domain
object type for documentation of such properties.
2014-05-28 12:28:18 -04:00
Ben Boeckel
270eb96df0 strings: Remove cmStdString references
Casts from std::string -> cmStdString were high on the list of things
taking up time. Avoid such implicit casts across function calls by just
using std::string everywhere.

The comment that the symbol name is too long is no longer relevant since
modern debuggers alias the templates anyways and the size is a
non-issue since the underlying methods are generated since it's
inherited.
2014-03-08 13:05:35 -05:00
Clinton Stimpson
5730710c86 Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.
Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
2014-01-07 09:27:44 -05:00