Commit Graph

677 Commits

Author SHA1 Message Date
Martin Duffy
97adbc91fa instrumentation: Move target data into content files
Create a single place to store target data to prevent duplication.
This moves `targetType` and `targetLabels` out of the snippet files
and into a target map in the `cmakeContent` file referenced by each
snippet.

Fixes: #27244
2025-10-02 09:28:20 -04:00
Martin Duffy
e730008d7e instrumentation: Record build snippets regardless of hooks 2025-09-26 15:55:08 -04:00
Martin Duffy
2fdd1e787f instrumentation: Additional data in custom, install and link snippets
- Include `config` in all `install` and `custom` snippets
- Include `target` for `custom` snippets where applicable
- Document and test inclusion of `language` in `link` snippets

Issue: #27244
2025-09-24 16:39:09 -04:00
Ben Boeckel
8180ecad9b autogen: support the SHORT intermediate dir strategy 2025-07-29 09:44:03 -04:00
John Parent
3f33a5387a Makefiles: support shortened object filenames 2025-07-29 08:28:22 -04:00
Ben Boeckel
b121adaa04 Makefiles: pass the target name to cmake -E cmake_depends
When a shortened directory is used, the name of the target is not
accessible just by the path. Pass it explicitly.
2025-07-29 08:06:30 -04:00
Ben Boeckel
dcba9ed828 Makefiles: populate the TARGET_SUPPORT_DIR replacement variable 2025-07-28 12:01:27 -04:00
Tyler Yankee
f7756853c5 instrumentation: Exclude (pre|post)Build hooks with MSYS Makefiles
The implementation of (pre|post)Build hooks rely on a direct parent-
child relationship between the build system process and `ctest
--start-instrumentation`. MSYS2's `make.exe` uses the msys-runtime POSIX
compatibility layer which disrupts this relationship.
2025-07-22 11:06:41 -04:00
Tyler Yankee
7dbe092d77 instrumentation: Support preBuild and postBuild hooks on Windows
* Use `uv_disable_stdio_inheritance` to resolve the deadlock between the
parent build system process and `ctest
--wait-and-collect-instrumentation` on Windows.
* Remove Windows gating from preBuild and postBuild indexing and update
tests and documentation accordingly.

Fixes: #26668
2025-07-22 10:51:03 -04:00
Ben Boeckel
35d32b8741 cmLocalGenerator: move the CMakeFiles subdir from the target to output root
When target directories are shortened, the `CMakeFiles` path component
will be part of the root, not the target directory. Since other files
end up constructing paths manually, move the differing component into
the correct logical path construction part.
2025-05-24 15:28:47 +02:00
Ben Boeckel
b82a74d918 generators: use GetSupportDirectory() in more places 2025-05-23 11:39:53 +02:00
John Parent
a6da0b08b7 cmLocalCommonGenerator: factor out GetTargetDirectory 2025-05-22 17:02:53 +02:00
Ben Boeckel
4abd800498 cmLocalUnixMakefileGenerator3: use faster rfind overload 2025-05-22 16:02:49 +02:00
Brad King
6be0c6d26a Merge topic 'astgrep-cmstrcat'
557c44b93e cmStrCat: use character literals where possible
23779057fd cmStrCat: combine neighboring arguments where possible
483d13daf4 ast-grep: add a rule to turn strings into characters
61743471d9 ast-grep: add a rule to find adjacent string literals in cmStrCat calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10790
2025-05-22 08:47:15 -04:00
Brad King
509c424472 StdIo: Replace uses of KWSys Terminal with StdIo::Print
The latter:

* uses a type-safe representation of text attributes,

* works with `StdIo::Console` to print arbitrary UTF-8 text in color, and

* writes VT100 sequences to Windows Consoles when supported, eliminating
  racy console text attribute changes in parallel `make` output.

Fixes: #22450, #26689, #26924
2025-05-19 08:19:10 -04:00
Brad King
03c97133e8 Makefile: De-duplicate dependency message color code 2025-05-16 15:06:24 -04:00
Ben Boeckel
557c44b93e cmStrCat: use character literals where possible
Found and replaced using the `cmstrcat-to-char-literal` rule for
`ast-grep`.
2025-05-15 19:12:04 +02:00
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