1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-10 16:21:40 +08:00

120 Commits

Author SHA1 Message Date
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Marc Chevrier
96a953b1ed Add options to specify linker tool
Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as
the target property `LINKER_TYPE` to specify which linker must be used.

The implementation of this capability is specified by variables specific
to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`.
Some definitions are provided as part of `CMake`.

For example, to select the `LLVM` linker rather than the standard one,
the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`.
And, on `Apple`, `Linux` and some environments on `Windows`, the variable
`CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows`
environments  based on `MSVC`, where the linker is used directly, the tool
`lld-link.exe` will be used rather than `link.exe`.

Fixes: #19174, #24254, #24990
2023-10-13 11:52:35 +02:00
Brad King
b931fbd1b8 Merge topic 'ghs-escape-custom-command-comments'
5a41d926dd GHS: Escape custom command comments

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8714
2023-08-16 09:46:36 -04:00
William Sciaroni
5a41d926dd GHS: Escape custom command comments
Fixes: #25171
2023-08-15 09:53:41 -04:00
Brad King
241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Peter Würth
60a5a39022 cmCustomCommandGenerator: refactor GetComment to return std::string
Refactoring was done because EvaluateComment leaked memory.
2022-11-19 13:32:56 +01:00
Robert Maynard
96bc59b1ca CUDA: Add Device LTO support for nvcc
Fixes #22200
2022-07-22 10:34:45 -04:00
Fred Baksik
158d6252cc GHS: Set LANGUAGE type for source files
Use gbuild project syntax for setting the language type for the file.
gbuild will pick the correct compiler or tool to use.

NOTE: Language names come from gbuild config files.  Therefore to
compile a file with the C++ compiler use "C++" not "CXX".

The previous implementation was passing the C compiler a flag to compile as C++
if LANGUAGE was set to "CXX".
2022-04-27 10:33:51 -04:00
Fred Baksik
724b5491ef GHS: Rearrange project files in binary directory
The top level project and the target projects are all in the same
directory so they are easier to find and looks nicer in the GUI.

All of the ancillary project files are located in the target
subdirectory.
2022-03-17 19:11:44 -04:00
Brad King
51e81d1f73 Merge topic 'color-diagnostics'
6ab9fbd43b color: Add tests for CMAKE_COLOR_DIAGNOSTICS
78adb1b952 color: Add CMAKE_COLOR_DIAGNOSTICS environment variable
884d9de8b7 color: Introduce CMAKE_COLOR_DIAGNOSTICS variable

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Frank Dana <ferdnyc@gmail.com>
Merge-request: !6990
2022-03-09 12:15:53 -05:00
Semyon Kolton
884d9de8b7 color: Introduce CMAKE_COLOR_DIAGNOSTICS variable
Add a variable to control both makefile color messages and compiler
color diagnostics.

Fixes: #15502
2022-03-08 16:37:08 -05:00
Fred Baksik
6acf06a2cd GHS: fix build event script error on Linux
On Linux run build events scripts as "/bin/sh script.sh".
Prefer using _WIN32 over variable for host platform decisions.
  -- This is consistant with other parts of CMake.
2022-02-16 22:35:47 -05:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Lawrence A
172475b2c5 GHS: Remove bashism from custom command shell scripts 2021-07-28 19:13:14 +01:00
Brad King
15fa320071 cmLocalGenerator: Factor out relative path conversion helpers
Most calls to `MaybeConvertToRelativePath` use one of our common work
directories (e.g. top of the build tree) as the local path.  Add helpers
for each of the common cases to simplify and clarify call sites.
2021-05-13 12:47:25 -04:00
Vitaly Stakhovsky
ce97b7909b Source: Remove unnecessary comparisons to nullptr 2021-05-10 11:44:53 -04:00
Ben Boeckel
ef935b17ab clang-tidy: fix readability-use-anyofallof warnings 2021-01-27 08:54:18 -05:00
Ben Boeckel
cdfc4e3195 clang-tidy: fix readability-qualified-auto warnings 2021-01-27 08:45:45 -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
Vitaly Stakhovsky
f6e7d5f3a0 Reduce the scope of temporary cmProp variables and other improvements 2020-11-05 11:07:39 -05:00
Brad King
0090a11a42 cmLocalGenerator: Migrate custom command output lookup from cmMakefile
Since commit 777ceaea94 (cmMakefile: Delay custom command creation,
2019-10-17, v3.17.0-rc1~352^2) we process custom command declarations at
generate time.  Therefore we do not need to look up what source file
holds the custom command producing a given output until generate time.
2020-10-08 12:20:33 -04:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Vitaly Stakhovsky
7156911242 cmIsOn: add overload accepting const std::string* 2020-07-14 08:22:24 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Brad King
c09efe074d Merge topic 'gitlab-ci-lint'
4318e8ed35 gitlab-ci: add iwyu job
0866b9253b gitlab-ci: add initial clang-tidy build
0a5bcf97b9 gitlab-ci: add scripts for use by CI
960158b90d ci: add scripts to download build tools
6af91c7c4d ci: add an image for Debian 10
68903ae238 ci: add a Docker container for building CMake
3ac24a8a6e cmFunctionBlocker: include missing header
b745b8fd36 IWYU: mark includes needed for assert statements as needed
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4643
2020-04-30 10:00:02 -04:00
Ben Boeckel
a58457a6c2 IWYU: mark cmLinkLineComputer as necessary
IWYU is not seeing that the full declaration is necessary for
`std::unique_ptr<cmLinkLineComputer>`.
2020-04-29 11:16:44 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -04:00
Vitaly Stakhovsky
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp 2020-04-14 10:57:17 -04:00
Alex Turbov
8e3a65d963
Refactor: Avoid std::endl where it's not necessary (part 3)
The `std::endl` manipulator, except inserting `\n` character, also
performs `os.flush()`, which may lead to undesired effects (like
disk I/O in the middle of forming data strings). For the
`std::stringstream` it also has no meaning.

* replace multiple `operator<<` calls on a string literal w/
  the only call and the only (bigger) string literal;
* replace one character string literal used in `operator<<`
  w/ a char literal.
2020-03-24 21:33:33 +08:00
Brad King
c7c6e103d1 Merge topic 'loops-improve'
cbbca9ee2a Convert more loops to range-based for-loops
9296cd0551 GHS: Name range-based for-loop variable types explicitly
db17de2438 GHS: Use cm::erase in place of loop

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4446
2020-03-11 09:27:24 -04:00
Vitaly Stakhovsky
9296cd0551 GHS: Name range-based for-loop variable types explicitly
In general we avoid using `auto` except in cases of hard-to-name types
like iterators.
2020-03-10 14:25:53 -04:00
Vitaly Stakhovsky
a6cd48ac41 Source: use std::string overloads 2020-03-10 10:55:09 -04:00
Marc Chevrier
5444a8095d cmGlobalGenerator: modernize memrory managemenbt 2019-12-30 16:55:39 +01:00
Vitaly Stakhovsky
c34b4497f8 cmTarget: add std::string overloads 2019-12-14 09:30:28 -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
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
Daniel Eiband
2d888e3390 cmSourceFile: Rename mutating GetFullPath() overload
Rename mutating GetFullPath() overload to ResolveFullPath().
2019-08-29 22:51:58 +02:00
Sebastian Holtermann
aaf59120bf Source sweep: Replace cmExpandList with the shorter cmExpandedList
This replaces the code pattern
```
std::vector<std::string> args;
cmExpandList(valueStr, args, ...)
```
with
```
std::vector<std::string> args = cmExpandedList(valueStr, ...)
```
2019-08-23 17:07:49 +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
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
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
Fred Baksik
83c47ef5b8 GHS: Update project layout to accommodate gbuild inconsistencies
-- Do not use reference projects, use build hierarchy instead.
   gbuild has three parallel levels:
   * low -- Parallelizes compiling source files within a single project (.gpj)
     file when safe to do so.
   * medium -- Parallelizes processing files within a single linked output when
     safe to do so.
   * high [default] -- Parallelizes processing files whenever safe to do so,
     including linking task.

   Testing showed that for some combinations of gbuild / MULTI there are issues
   with building a project that uses references to target project files along with
   using {nobuild} option.

   Sometimes the archiving of a library and linking of an executable were
   happening in parallel and the build would fail when linking because the
   archive wasn't complete.

   This behavior was also inconsistent when running the build from MULTI and
   from the command line with gbuild. In some cases MULTI did not parallelize
   archiving and linking, but gbuild performed these actions in parallel.

   The parallel build issue was not seen when using a build hierarchy where the
   project listed the project files normally instead of using a reference link.

   The other option was to add the -parallel_level=medium to the command line
   when using "cmake --build" but this wouldn't fix the issue if gbuild itself
   was used to and the user might not be aware of the extra option used by cmake.
2019-04-11 13:15:51 -04:00
Fred Baksik
5d2e1404bd GHS: Update project layout to build targets correctly
-- Restructure projects and files to support proper building of targets
   Build order is determined by hierarchy of project files and folders
   Custom targets may have been run multiple times in the original file / folder structure
-- Default to build targets that are part of ALL target
-- List all known targets for this project
   Includes global targets for ALL_BUILD and INSTALL
-- Compute build order for building targets
2019-04-11 13:15:50 -04:00
Fred Baksik
b6bfa7eeb2 GHS: Support add_dependencies() command
-- use references to list target dependencies
2019-04-11 13:15:50 -04:00
Fred Baksik
39ee9718d9 GHS: Support add_custom_target() command
-- add new project type that runs shell scripts in proper order
2019-04-11 13:15:50 -04:00
Fred Baksik
8d3dad9a76 GHS: Support add_custom_command( OUTPUT ) signature
-- add new file type to run a shell script
-- gbuild does not compute interfile dependencies like other build tools.
   Therefore calculate the required build order of custom commands and
   list all of them in the CMake Rules subproject.
2019-04-11 13:15:50 -04:00
Fred Baksik
37acc9e229 GHS: Update custom command build events
-- Fixes issue where commands run out of order; Run commands as single script
   Do not allow build events to run in parallel
-- Use command generator to parse the commands
-- Support pre-link build events
-- Support more options: COMMENT, BYPRODUCTS, WORKING_DIRECTORY
2019-04-10 11:54:56 -04:00