Commit Graph

101 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
Brad King
659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Brad King
9d44a77454 find_*: Explicitly normalize found paths as they exist on disk 2024-10-22 13:26:19 -04:00
Brad King
808ae84483 cmFind*Command: Simplify file validation code paths 2024-10-22 11:21:31 -04:00
Brad King
fbd5d4e87f cmFind*Command: Store candidate paths as local variables 2024-10-22 11:21:31 -04:00
Brad King
9fb1caa1b9 cmFindProgramCommand: Remove stray cut-n-paste comment
In commit ef935b17ab (clang-tidy: fix `readability-use-anyofallof`
warnings, 2021-01-22, v3.20.0-rc1~95^2) a comment was copied to a
location where it doesn't make sense.
2024-10-22 11:21:31 -04:00
Vitaly Stakhovsky
58da4aa47d Source: Avoid comparing pointers to nullptr 2024-08-27 10:56:38 -04:00
Marc Chevrier
f3b5a7d6df find_(program,library,file,path): add validation function
Fixes: #23603
2022-06-14 16:17:46 -04:00
Marc Chevrier
8d7e80cf3d find_* commands: add control over Windows registry views
Fixes: #22775
2022-04-29 22:00:02 +02:00
John Parent
d7b18895bc cmake: Add filtered debug-find options
Add a `--debug-find-pkg=` option to debug find calls for specific
packages.

Add a `--debug-find-var=` option to debug find calls for specific
return variables.

Fixes: #21880
2021-12-17 08:55:21 -05:00
Brad King
37c2f722fc find_program: Explicitly skip WindowsApps/python*.exe app installer links
Windows provide a "python" executable like this:

    %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\python.exe

It is actually a Windows app exec link.  If it points to an app
installer, avoid mistaking it for a working Python.
2021-11-01 09:03:51 -04:00
Marc Chevrier
87b71eec62 find_*: Add support for option NO_CACHE
Request that find result is stored in a normal variable rather than a
cache entry.

Fixes: #20687
Issue: #20743
2021-06-02 14:55:00 -04:00
Marc Chevrier
b1729200c3 find_*: refactor cache variable handling 2021-05-11 18:16:08 +02:00
Ben Boeckel
ef935b17ab clang-tidy: fix readability-use-anyofallof warnings 2021-01-27 08:54:18 -05:00
Oleksandr Koval
209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
Brad King
9d45a8be08 find_program: Find programs that are executable but not readable
This fix was first made by commit 86e6349ef7 (find_program: Find
programs that are executable but not readable, 2020-04-04,
v3.18.0-rc1~372^2) but was reverted for compatibility.  Re-introduce it
with a policy for compatibility.

Fixes: #10468
2020-06-15 11:58:47 -04:00
Brad King
148a5c2d42 Merge topic 'bundle-exe-space-in-name'
d3fd518c03 find_program: Properly decode URL for bundle exe name with spaces

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4891
2020-06-15 09:36:22 -04:00
Craig Scott
d3fd518c03 find_program: Properly decode URL for bundle exe name with spaces
Fixes: #20817
2020-06-14 18:21:35 +10:00
Brad King
cc02ced530 find_program: Revert "Find programs that are executable but not readable"
The fix in commit 86e6349ef7 (find_program: Find programs that are
executable but not readable, 2020-04-04, v3.18.0-rc1~372^2) can break
existing projects that were (likely accidentally) relying on the
old behavior to find files that are readable but not executable.
Revert the fix for now.  We can re-introduce it with a policy later.

Instead of reverting the test case, update it to cover the old behavior.
That can serve as a reference for testing the policy when introduced.

Fixes: #20814
Issue: #10468
2020-06-12 05:04:56 -04:00
Vladimir Menshakov
86e6349ef7 find_program: Find programs that are executable but not readable
`find_program` internally uses `cmSystemTools::FileExists`
which calls `access(R_OK)` instead of `access(X_OK)`.
Use `cmSystemTools::IsFileExecutable` instead to fix this
issue.  An example of such a program is `sudo`.

Fixes: #10468
2020-04-09 08:08:50 -04:00
Vitaly Stakhovsky
36a5b3d1d1 cmMakefile::AddCacheDefinition: Add overload that accepts std::string value 2020-03-11 09:40:43 -04:00
Sylvain Joubert
dc00809596 find_*: Add support for REQUIRED keyword
In the same spirit as the REQUIRED keyword on find_package, this will
stop cmake execution with an error on a failed find_program, find_file,
find_path or find_library.
2020-03-06 16:40:26 +01:00
Robert Maynard
204b8d9f4e find_*: Use debug logging infrastructure
Teach the find_package, find_library, find_program, find_path, and
find_file commands to print debug log messages when enabled by the
`--debug-find` command-line option or `CMAKE_FIND_DEBUG_MODE` variable.
2019-12-19 08:09:49 -05:00
Regina Pfeifer
8a18bb7cdf cmFind*: Port away from cmCommand 2019-09-10 22:13:11 +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
Sebastian Holtermann
a693e875db Cleanups: Use cmHas{Prefix,Suffix} instead of String{Starts,Ends}With 2019-08-01 13:33:00 +02:00
Brad King
00c4ddf75e find_program: Restore leading double slash on Windows network path
Since commit c76c1ea208 (find_program: Consider CWD only for paths with
separator, 2018-05-31, v3.13.0-rc1~413^2) we accidentally convert the
leading `//` to just `/` on results with Windows network paths.

This was caused by `CollapseCombinedPath` being less robust than
`CollapseFullPath`.  Restore use of the latter but in a way that
preserves the requirement of the above commit to support candidates that
are themselves absolute.

Fixes: #19049
Issue: #19050
2019-03-14 14:46:23 -04:00
Sam Yates
c76c1ea208 find_program: Consider CWD only for paths with separator
find_program() incorrectly prepended search path components
to absolute file paths, and incorrectly searched the current
working directory for files that contained no directory
separators.

* Replace calls cmFindProgramHelper::CheckDirectory(std::string())
  with call of new method cmFindProgramHelper::CheckCompoundNames()
  that checks for the presence of a directory separator in the
  file name.
* Use cmSystemTools::CollapseCombinedPath rather than string
  concatenation to properly combine absolute file names with
  search path components.
* Add unit tests to verify corrections.

Fixes: #18044
2018-06-14 14:28:03 -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
Pavel Solodovnikov
c85bb007df Reduce allocation of temporary values on heap.
- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
2018-01-26 13:24:45 +03:00
Pavel Solodovnikov
37d9387be3 Replace empty-string comparisons with checking against empty(). 2017-09-21 11:23:19 +03:00
Matthias Maennich
a5279ae553 Use C++11 nullptr (cont.)
Fix remaining occurrences of the issue addressed in commit 5962db4389
(Use C++11 nullptr, 2017-08-22) that are only showing up on macOS.

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-19 11:44:21 -04: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
b1ec5deaf1 Pass large types by const&, small types by value 2017-06-04 00:48:21 +02:00
Daniel Pfeifer
a74e689348 clang-tidy: apply readability-redundant-string-init fixes 2016-12-12 14:04:13 -05:00
Daniel Pfeifer
e81c323da9 Include necessary headers in commands 2016-10-26 09:02:44 +02:00
Daniel Pfeifer
64f9c282f3 Separate compilation for commands included in cmBootstrapCommands1 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
516f8edb2e Avoid else after return 2016-09-16 22:45:24 +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
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
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
Brad King
31e6571cca find_program: Fix regression in finding an already-known path
Changes in commit v3.4.0-rc1~124^2~1 (cmFindProgramCommand: Re-implement
search using more flexible approach, 2015-09-01) did not preserve the
behavior of looking for the given name with no search path at all.
Fix this and add a test case covering finding an absolute path with
no search directories.
2015-10-30 07:40:46 -04:00
Brad King
8ea7611bc3 find_program: Optionally consider all names in each directory
When more than one value is given to the NAMES option this command by
default will consider one name at a time and search every directory for
it.  Add a NAMES_PER_DIR option to tell this command to consider one
directory at a time and search for all names in it.
2015-09-02 10:17:22 -04:00
Brad King
fc1990c933 cmFindProgramCommand: Re-implement search using more flexible approach
Avoid using KWSys SystemTools::FindProgram because it does much more
than we actually need for find_program and does not allow us to control
the order of preference between directories and names.  Create our own
cmFindProgramHelper much like cmFindLibraryHelper but without all the
find_library-specific parts.
2015-09-02 10:17:22 -04:00
Brad King
ed4de3c984 cmFindProgramCommand: Use Names member instead of passing it 2015-09-02 10:17:21 -04:00
Stephen Kelly
f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Stephen Kelly
5eb4d7590e Remove some unneeded c_str calls. 2014-11-23 11:09:54 +01:00