Commit Graph

130 Commits

Author SHA1 Message Date
Neil Carlson
f7f60ddcf9 Fortran: Add support for NAG Fortran submodules
They use a `.sub` extension.

Fixes: #20220
2020-01-15 14:12:22 -05: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
Regina Pfeifer
a1ddf2d0ba clang-tidy: Replace typedef with using
Automate the conversion with

  perl -i -0pe 's/typedef ([^;]*) ([^ ]+);/using $2 = $1;/g'

then manually fix a few places.
2019-09-04 18:03:01 +02:00
Regina Pfeifer
62e5f72289 clang-tidy: Replace typedef with using 2019-09-03 13:21:26 -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
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +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
Artur Ryt
2d66567dca Modernize: Prefer .substr in place of .c_str() + int
A lot of temporary/local strings were created out of C-strings
substr can utilize current string size, so in theory be a little
more efficient.
2019-03-30 16:15:05 +01:00
Brad King
d80ecba5c2 Fortran: Fix submodule file names across compilers
The naming convention for submodule files varies across compilers.  Add
a table to the compiler information modules and thread the information
through to the Fortran module dependency parser.  Fill out the table for
compiler ids known to support Fortran submodules.

Fixes: #18746
2019-02-14 10:23:02 -05:00
Brad King
72057d9c15 Fortran: Thread compiler id through to internal Fortran parser 2019-02-14 10:23:02 -05: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
Vitaly Stakhovsky
2c50a72576 cmDepends: all members accept std::string arguments
Most `const char*` arguments converted to `const std::string&`
in `cmDepends` and derived classes.
In addition performed minor code cleanup.
2019-01-18 20:30:13 -05:00
Regina Pfeifer
b2aa3aedea clang-tidy: Use default member initialization 2018-12-15 10:52:37 +01:00
Bruno Manganelli
33f08eec18 cmOutputConverter: Moved ContainedInDirectory to cmStateDirectory 2018-12-08 11:24:06 +00:00
Bruno Manganelli
87e810f223 cmOutputConverter: Moved ForceToRelativePath to cmSystem 2018-12-07 19:29:30 +00:00
Sebastian Holtermann
b6802cd506 cmGeneratedFileStream: clang-tidy applied to remove redundant `c_str` calls
After changing the ``cmGeneratedFileStream`` methods to accept
``std::string const&`` instead of ``const char*`` we don't
need to call ``std::string::c_str`` anymore when passing
a ``std::string`` to a ``cmGeneratedFileStream`` method.

This patch removes all redundant ``std::string::c_str``
calls when passing a string to a ``cmGeneratedFileStream`` method.

It was generated by building CMake with clang-tidy enabled using
the following options:

-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-4.0;-checks=-*,readability-redundant-string-cstr;-fix;-fix-errors
2018-08-07 17:02:39 +02:00
Brad King
402735314e Fortran: Add support for submodule dependencies
Since commit v3.7.0-rc1~73^2~1 (Fortran: Add support for submodule
syntax in dependency scanning, 2016-09-05) we support parsing Fortran
sources that use submodule syntax, but it left addition of `.smod`
dependencies to future work.  Add it now.

The syntax

    submodule (module_name) submodule_name

means the current source requires `module_name.mod` and provides
`module_name@submodule_name.smod`.  The syntax

    submodule (module_name:submodule_name) nested_submodule_name

means the current source requires `module_name@submodule_name.smod`
provides `module_name@nested_submodule_name.smod`.

Fixes: #17017
2018-04-20 10:57:31 -04:00
Brad King
62538b2c4c Fortran: Refactor to treat .mod extension as part of module name
When tracking module names internally, include the `.mod` extension.
This will later be useful to distinguish them from `.smod` extensions
for submodules.
2018-04-20 10:56:54 -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
Luz Paz
3ab7bf8285 Various typo fixes
Some are user-facing. Others are source comments.
2018-01-04 06:52:01 +11:00
Yurii Batrak
7ab9a62572 Makefiles: Drop 'requires' step and its supporting infrastructure
The 'requires' step was used to provide implicit dependencies between
the generated Fortran module files and a Fortran target that needs these
module files to ensure the correct compilation order.  After recent
refactoring to resolve all dependencies explicitly through `.mod.stamp`
make targets, the separate 'requires' step is not needed anymore.
2017-12-14 08:22:07 -05:00
Yurii Batrak
5f2e2c387d Makefiles: Avoid nested make calls for Fortran module dependencies
Makefiles generated by cmake use a series of nested calls to build
`*.provides.build` targets that are used when the 'requires' step is
needed.  That leads to significant degradation of the build time for
incremental builds.  Re-arrange dependencies to eliminate the nested
calls.

Explicit `.mod.stamp` targets introduced by this commit could lead to
situation when a stamp file always older than its dependency.  This
happens during the incremental build when building of an updated Fortran
source produces a module file that has no differences from the stored
stamp file.  In such case `cmake_copy_f90_mod` will be triggered on each
new build to compare a module file with the corresponding stamp file.
This behavior is expected and can not be changed without nested calls
that slow down the build.  The copy-if-different check is much cheaper
than an entire nested make call.
2017-12-14 08:13:42 -05: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
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +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
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Stephen Kelly
e0a84904eb cmState: Split auxiliary classes into separate files
Port dependents to the new locations as needed.

Leave behind a cmState.h include in cmListFileCache to reduce noise. It
is removed in a following commit.
2016-10-19 15:40:59 +02:00
Stephen Kelly
8377d9e00b Fortran: Inline conversion to relative path
Don't use cmOutputConverter method which relies on directory-specific
state.
2016-10-06 20:02:08 +02:00
Stephen Kelly
00173b71d9 Fortran: Wrap path convert in a call with a more-suitable name 2016-10-06 20:02:07 +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
Stephen Kelly
4d69ac7697 Convert: Move access to BinaryDirectory out of loops 2016-09-19 21:36:14 +02:00
Stephen Kelly
e7c8956746 Convert: Inline uses of HOME_OUTPUT 2016-09-19 21:36:14 +02:00
Stephen Kelly
1825f876a7 Convert: Move access to BinaryDirectory out of loops 2016-09-19 21:36:13 +02:00
Stephen Kelly
25c39ac28b Convert: Inline HOME_OUTPUT MAKERULE conversion 2016-09-19 21:36:13 +02:00
Stephen Kelly
516e79ba27 Convert: Inline MAKERULE conversions
This is a trivial use of a static method.
2016-09-19 21:36:13 +02:00
Stephen Kelly
34c6e995f9 Convert: Avoid HOME_OUTPUT enum when converting to relative paths 2016-09-19 21:36:13 +02:00
Stephen Kelly
839c65bca0 Convert: Move access to CurrentBinaryDirectory out of loops 2016-09-19 21:36:12 +02:00
Stephen Kelly
21b5fdf9a3 Convert: Avoid START_OUTPUT enum when converting to relative paths 2016-09-19 21:36:12 +02:00
Daniel Pfeifer
73128b823c cmDependsFortran: simplify boolean expression 2016-09-12 09:28:21 -04:00
Brad King
e11cd31fa0 Fortran: Warn when dependency scanning fails to parse a source file
We expect to handle all relevant statements and ignore those that we do
not understand.  Warn if this process ever fails.  Otherwise dependency
information may be silently left out.
2016-09-06 15:40:04 -04:00
Daniel Pfeifer
efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -04:00
Stephen Kelly
563ac22a16 Convert: Replace trivial conversion with new method 2016-08-27 15:26:37 +02:00
Brad King
ce8fadc717 Merge topic 'intel-fortran-mod-diff'
f699323a Fortran: Fix .mod file comparison for Intel 16 format
2016-08-25 09:50:35 -04:00
Brad King
f699323ade Fortran: Fix .mod file comparison for Intel 16 format
The Intel 16 format starts with the 0x0A 0x00 sequence that we use to
skip past the timestamp.  This occurrence appears to be a version
number.  Skip the first byte to avoid matching the sequence early.

Ideally we should gain a better understanding of the format and avoid
depending on short sequences that are likely to appear early by
coincidence, but this approach will suffice for now.

Closes: #16263
2016-08-24 11:55:29 -04:00
Daniel Pfeifer
7b6349da4d CMake: don't use else after return 2016-08-18 20:36:29 +02:00
Daniel Pfeifer
e7b842e189 Make sure unnused parameters are /*named*/ 2016-08-17 01:49:57 +02:00
Daniel Pfeifer
1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00