Commit Graph

252 Commits

Author SHA1 Message Date
Robert Maynard
6c92df382f find_package: Improve debug logging output
The find_package debug log messages are now easier to read when enabled by the
`--debug-find` command-line option or `CMAKE_FIND_DEBUG_MODE` variable.
2020-01-01 15:00:42 -05: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
Robert Maynard
55df3954d3 find_package: Add support for CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
Extend the change from commit 1d00ba9ccf (Find: find_package prefers
variable CMAKE_FIND_USE_REGISTRY, 2018-11-13, v3.16.0-rc1~461^2~1)
to cover the system package registry too.

Fixes: #19890
2019-11-04 10:31:16 -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
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04: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
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Brad King
1a1508c8b8 Merge topic 'modernize-use-auto'
d25a5a7ec9 clang-tidy: modernize-use-auto

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3783
2019-09-12 09:15:38 -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
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
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
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Brad King
ce14f6c677 Merge topic 'find_package-prefer-config-not-found'
8ed868606d find_package: Fix prefer-config mode to not fail on missing optional package

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3653
2019-08-07 09:57:35 -04:00
Cristian Adam
8ed868606d find_package: Fix prefer-config mode to not fail on missing optional package
When `CMAKE_FIND_PACKAGE_PREFER_CONFIG` mode was set to `ON`, failure to
find a package was fatal even if it was not `REQUIRED`.  Fix this and
add a test case.

Fixes: #19557
2019-08-06 09:36:36 -04: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
467e6ac728 Merge topic 'definitions_string_view'
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
f2ba968ef2 cmMakefile: Simplify and rename AddDefinitionBool
9b5cc42531 cmDefinitions: Remove const char* based Set method
e268840c0a cmDefinitions: Add Unset and cm::string_view based Set methods
451fd329a8 cmDefinitions: Cleanups

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3577
2019-07-26 07:32:18 -04: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
Robert Maynard
609fe39043 FindPackage: Support NO_[]_PATH global call options 2019-07-22 17:17:02 -04:00
Brad King
3f84ff212c Merge topic 'find_package-fix-NO_MODULE'
f2edccea66 find_package: Fix NO_MODULE under CMAKE_FIND_PACKAGE_PREFER_CONFIG

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3557
2019-07-17 07:20:20 -04:00
Cristian Adam
f2edccea66 find_package: Fix NO_MODULE under CMAKE_FIND_PACKAGE_PREFER_CONFIG
The module mode fallback added by commit 22e65d10c1 (find_package: Fixed
CMAKE_FIND_PACKAGE_PREFER_CONFIG Module fallback, 2019-06-13,
v3.15.0-rc2~6^2) should not be used unless the `find_package` call
allows module mode.  Doing so can lead to infinite recursion if a find
module tries to call config mode with `find_package(...  NO_MODULE)`.
Fix the logic and add a test case.

Fixes: #19478
2019-07-16 09:09:24 -04:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -04:00
Craig Scott
f7eb765012 Merge topic 'add_cmake_find_use_package_registry'
447a96f590 vim: Update cmake.vim to include the CMAKE_FIND_USE variables
1d00ba9ccf Find: find_package prefers variable CMAKE_FIND_USE_REGISTRY
704e3a2ca8 Find: Correct spelling and layout issues in CMAKE_FIND_USE_ docs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3487
2019-07-09 19:32:54 -04:00
Robert Maynard
1d00ba9ccf Find: find_package prefers variable CMAKE_FIND_USE_REGISTRY
CMake's find control flags should all have a consistent name.
To make this happen we are introducing `CMAKE_FIND_USE_REGISTRY`
and deprecating `CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`.
2019-07-09 09:38:35 -04:00
Robert Maynard
96b10e47be Remove unused variables from cmFindPackageCommand 2019-06-26 16:06:21 -04:00
Cristian Adam
22e65d10c1 find_package: Fixed CMAKE_FIND_PACKAGE_PREFER_CONFIG Module fallback
Fixes: #19361
2019-06-13 23:58:30 +02:00
Cristian Adam
26a99da206 find_package: Add option to prefer Config mode
Add a `CMAKE_FIND_PACKAGE_PREFER_CONFIG` variable to tell
`find_package` calls to look for a package configuration file
first even if a find module is available.

Fixes: #16805, #19236
2019-05-21 10:29:47 -04:00
Cristian Adam
c365243a3a find_package: Factor out module and config find_package methods 2019-05-20 21:20:10 +02:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -05:00
Albert Astals Cid
ae5e97a005 Delete some default constructors and assignment operators
They are unused, but if someone used them they would lead to
problems since they would copy the internal raw pointers
and the destructor would cause double delete
2019-02-15 07:25:47 -05:00
Vitaly Stakhovsky
950c099d83 cmake: Progress functions use std::string param 2019-02-11 10:32:43 -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
Artur Ryt
f3534386b5 Prefer front/back/data over dereferencing begin/rbegin iter
Changed for sequenced containers: vector, list, string and array
2019-02-06 10:43:16 -05:00
Vitaly Stakhovsky
0779bc9393 ReadListFile: Accept std::string argument 2019-01-31 09:27:54 -05:00
Regina Pfeifer
094f01d0f0 cleanup: Prefer compiler provided special member functions 2019-01-25 06:45:00 -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
Brad King
a7f5cd45e1 Merge topic 'tidy-pass-by-value'
5a0784ddea clang-tidy: Pass by value

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2836
2019-01-23 08:17:49 -05:00
Regina Pfeifer
5a0784ddea clang-tidy: Pass by value 2019-01-22 13:03:04 -05:00
Vitaly Stakhovsky
2993fc347a cmMakefile: GetModulesFile() accepts std::string param 2019-01-21 12:56:51 -05:00
Brad King
4dba5d6ce2 Merge topic 'use-emplace'
ef61997b1b clang-tidy: Use emplace
2e5307a2a4 CTestSVN: Accept std::string in SVNInfo constructor

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2811
2019-01-21 07:51:54 -05:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
David Aguilar
a5e948a36f find_package: optionally resolve symlinks when discovering packages
Teach find_package() to resolve symlinks when constructing
relocatable prefix paths from discovered cmake config files.
The `CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS` variable enables
this behavior when set to `TRUE`.

Fixes: #18704
2019-01-16 09:59:46 -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
Regina Pfeifer
b2aa3aedea clang-tidy: Use default member initialization 2018-12-15 10:52:37 +01:00
Regina Pfeifer
32cb564bea clang-tidy: Remove redundant member initializations 2018-12-15 10:51:47 +01:00
Kyle Edwards
0f5c1b404b find_package(): Add policy to remove the FindQt module
Removing FindQt.cmake gives Qt upstream a path forward to export its
own QtConfig.cmake files which can be found by find_package()
without having to explicitly specify CONFIG. Projects that still
want to use Qt3/4 can call find_package(Qt[34]), include(FindQt),
or add FindQt.cmake to their CMAKE_MODULE_PATH.
2018-11-14 15:05:06 -05:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Jean-Christophe Fillion-Robin
30d08bdce9 doc: Consistently use <PackageName> for describing the name of a package 2018-08-14 20:54:56 +10:00
Vitaly Stakhovsky
69ca85cc7f Remove unnecessary c_str() in RegularExpression::find calls 2018-08-07 15:28:24 -04:00