Commit Graph

660 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
Martin Duffy
ee3a55fc48 cmMakefileGenerator: Update GetConfigName to return const reference 2025-02-09 12:29:08 -05:00
Martin Duffy
314440c320 instrumentation: Run preBuild and postBuild hooks before and after make
Updates the preBuild and postBuild instrumentation hooks to run before and
after make is invoked.
2025-02-06 09:49:09 -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
Martin Duffy
9d34069ca8 instrumentation: Add targetLabels field to link snippets
Adds a new data field `targetLabels` to link snippets which contains a list of
text labels from the LABELS target property.
2025-01-17 11:07:30 -05:00
Martin Duffy
097d4fd1b5 instrumentation: Collect and record project build system metrics
Add a feature for collecting build instrumentation for CMake projects.

Issue: #26099
2025-01-15 09:16:50 -05:00
Alex Turbov
bdece1c754 Refactor: Optimize ostream::operator<<() calls for some generators 2024-12-11 19:40:41 +04:00
Brad King
77ae9d7585 Merge topic 'codegen-make'
25b43a5b7f Makefile: Enable progress messages for codegen target
af2b340a2e Makefile: Fix per-directory codegen target
b7e6c418e3 cmLocalUnixMakefileGenerator3: Simplify progress command generation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10085
2024-12-11 10:10:03 -05:00
Brad King
25b43a5b7f Makefile: Enable progress messages for codegen target
This was left out of commit 197cb419d1 (add_custom_command: Add CODEGEN
support, 2024-05-27, v3.31.0-rc1~394^2).
2024-12-10 11:36:29 -05:00
Brad King
af2b340a2e Makefile: Fix per-directory codegen target
Issue: #26517
2024-12-10 11:36:29 -05:00
Brad King
b7e6c418e3 cmLocalUnixMakefileGenerator3: Simplify progress command generation 2024-12-10 11:36:29 -05:00
Marc Chevrier
7907c83175 Link step: Add LINK_WARNING_AS_ERROR target property
Add a way to specify, in a portable way, to raise an error for any
warning during the link step. For that purpose, define:
* CMAKE_LINK_WARNING_AS_ERROR variable
* LINK_WARNING_AS_ERROR target property

Fixes: #25343
2024-11-12 15:11:53 +01:00
Marc Chevrier
656267c871 COMPILE_WARNING_AS_ERROR: rename methods to prepare link similar functionality
Methods renamed:
* SetIgnoreWasinigAsError => SetIgnoreCompileWasningAsError
* GetIgnoreWasinigAsError => GetIgnoreCompileWasningAsError
2024-11-12 14:52:28 +01:00
Juan Ramos
197cb419d1 add_custom_command: Add CODEGEN support
By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.

The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.

This can be helpful for code analysis tools which can be useful
for IDEs and CI.
2024-07-01 12:02:49 -04:00
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
Ben Boeckel
f8729ab366 cmLocalUnixMakefileGenerator3: handle object-referencing Fortran modules
Targets only using Fortran modules via `$<TARGET_OBJECTS>` also need a
collation step to be performed. Check for this case and trigger the
depends rule to be used.
2023-11-21 09:43:49 -05:00
Chris Mahoney
3825d6ec98 add_custom_{command,target}: Teach JOB_SERVER_AWARE about WORKING_DIRECTORY
Issue: #16273
2023-07-25 11:34:22 -04:00
Ben Boeckel
8195aa3026 Makefiles: quote $(COLOR) expansions
This handles the case where `COLOR` is set to some ANSI-like color
sequence in the ambient environment. These sequences tend to include `;`
which terminates the command and tries to use the next component
(typically an integer, possibly with a trailing `m`) with errors like:

    /bin/sh: line 1: 2: command not found
    /bin/sh: line 1: 255: command not found
    /bin/sh: line 1: 221: command not found
    /bin/sh: line 1: 255m: command not found

Also add a test that sets `COLOR` in the environment which affects the
generated Makefiles behavior.

See: https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277
2023-06-08 11:05:11 -04:00
Brad King
da27ff1e96 Preserve --compile-no-warning-as-error in automatic CMake re-runs
When the build system re-runs `cmake` to regenerate itself, preserve the
`--compile-no-warning-as-error` option if it was used when `cmake` was
last explicitly invoked.  Normally such settings are preserved in the
cache, but the purpose of this option is to be beyond the reach of
project code.
2023-05-30 17:44:43 -04:00
Marc Chevrier
72faa9a017 CreateRulePlaceholderExpander(): enhance memory management
This method returns now a std::unique_ptr instance rather than a raw pointer.
2023-05-04 19:34:36 +02:00
Marc Chevrier
375e6fdbbe Link step: use linker dependency linker file
Based on work done by @ben.boeckel (!8051)

Fixes: #22217
2023-05-03 17:08:07 +02:00
Marc Chevrier
24a3e5cda0 cmLocalGenerator::MayBeRelativeToWorkDir: take care of all cases 2023-05-02 17:47:04 +02:00
Marc Chevrier
241304190f CMake code rely on cmList class for CMake lists management (part. 2) 2023-04-29 09:54:31 +02:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Kyle Edwards
78cf427157 RULE_LAUNCH_*: Add support for generator expressions 2023-02-03 11:23:32 -05: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
Marc Chevrier
9480ced81a Makefiles generator: dependencies messages in verbose mode
Fixes: #23689
2022-07-06 17:40:08 +02:00
FeRD (Frank Dana)
98a10290a8 cmSystemTools: Fix 'ErrorOccurred' spelling
Rename the booleans 's_ErrorOccured' and 's_FatalErrorOccured' to
's_ErrorOccurred' and 's_FatalErrorOccurred', respectively.

Rename the getters and setters to 'Get[Fatal]ErrorOccurred' and
'Set[Fatal]ErrorOccurred', and fix all uses across the codebase.
2022-06-13 09:05:24 -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
Brad King
43416c48ed cmOutputConverter: Always set relative path top source and binary together
Refactor to set both at once so we have a single place in the code that
knows both have been set.
2022-02-28 10:25:18 -05:00
Brad King
55db2cf1e5 Makefiles: Fix "make depend" with add_custom_command DEPFILE
Since commit cfd8a5ac1f (Makefiles: Add support of DEPFILE for
add_custom_command, 2020-12-04, v3.20.0-rc1~237^2~1) we store in
`CMAKE_DEPENDS_DEPENDENCY_FILES` an empty string as the source file with
which the dependencies of a custom command depfile are associated. When
this list is later expanded by `make depend`, the empty element is
removed and breaks list indexing.  Fix the list expansion to preserve
empty elements.
2022-02-28 09:46:59 -05:00
Brad King
ae101921e8 Source: Avoid gcc 12 compilation warning
GCC 12 warns:

    warning: '%04d' directive output may be truncated writing between
    4 and 11 bytes into a region of size 5 [-Wformat-truncation=]

The surrounding logic guarantees the formatted integer will never
be more than 4 bytes, but it doesn't hurt to use a larger buffer.
This GCC behavior is documented:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104012#c5
2022-01-28 08:06:13 -05:00
Sean McBride
5ba6e8ac59 Source: Replace most calls to sprintf with snprintf 2021-10-25 18:23:13 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Robert Maynard
b50bfc8913 HIP: Add language to CMake 2021-06-07 19:25:33 +00:00
Brad King
8526756b61 cmOutputConverter: Adopt relative path conversion helpers
Move them up from cmLocalGenerator and out of cmStateDirectory.
2021-05-17 10:04:01 -04:00
Brad King
d346805e41 cmLocalCommonGenerator: Select work directory semantically 2021-05-13 12:48:22 -04: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
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
Marc Chevrier
cfd8a5ac1f Makefiles: Add support of DEPFILE for add_custom_command
Issue: #20286
Fixes: #21415
2020-12-23 15:47:46 +01:00
Marc Chevrier
2c71d051fa Makefiles Generators: use compiler for dependencies generation
Each source compilation generates a dependencies file. These dependencies
files are consolidated in one file per target. This consolidation is done
as part of command 'cmake -E cmake_depends` launched before evaluation of
makefile dependency graph.

The consolidation uses the same approach as `CMake` dependencies management.

Fixes: #21321
2020-11-29 15:25:42 +01:00
Marc Chevrier
b6068ce407 Refactoring: enhance include file filtering
In preparation of support of 'CMAKE_DEPENDS_IN_PROJECT_ONLY'
when dependencies are generated by the compiler.
2020-11-28 16:02:58 +01:00
Marc Chevrier
a97c41bf8b Refactoring: Makefiles Generators: Add support for various depends scanners 2020-11-28 16:02:58 +01:00
vvs31415
f808f27919 cmLocalGenerator::GetRuleLauncher: return cmProp 2020-11-02 13:07:46 -05:00
Brad King
45fedf0e17 Makefile: Add policy CMP0113 to avoid duplication of custom commands
Do not attach a custom command to a target if it is already attached to one of
the target's dependencies.  The command's output will be available by the time
the target needs it because the dependency containing the command will have
already been built.

This may break existing projects that do not properly mark non-created
outputs with the `SYMBOLIC` property.  Previously a chain of two custom
commands whose intermediate dependency is not created would put both
commands in a dependent project's Makefile even if the first command is
also in its dependency's Makefile.  The first command would run twice
but the build would work.  Now the second command needs an explicit
`SYMBOLIC` mark on its input to tell CMake that it is not expected to
exist.  To maintain compatibility with projects that left out the mark,
add a policy activating the behavior.
2020-09-08 15:38:40 -04:00
Brad King
17aba9c9a6 cmLocalUnixMakefileGenerator3: Generate targets in dependency order
Use the globally computed target ordering so that we generate all
of a target's dependencies before generating the target itself.
2020-09-04 09:44:30 -04:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Robert Maynard
34cc6acc81 Add ISPC compiler support to CMake 2020-08-28 11:21:31 -04:00