1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-15 16:39:26 +08:00

1245 Commits

Author SHA1 Message Date
Brad King
62172b4ab7 Merge topic 'custom-command-comment-genex'
26d813092b add_custom_{command,target}: add genex support for COMMENT
60a5a39022 cmCustomCommandGenerator: refactor GetComment to return std::string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7887
2022-11-22 09:47:59 -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
Brad King
a1c20b08b4 cmLocalGenerator: Inline AddCompilerRequirementFlag in only call site
The call site in `AddLanguageFlags` is now the "one true place" for
adding language standard flags.  Inline the helper to reduce risk of
adding other call sites later.
2022-11-18 11:44:52 -05:00
Brad King
914571a042 Place language standard flags just after CMAKE_<LANG>_FLAGS
Previously we added the language standard flag near the end of all
options, even after those added by `add_compile_options` and friends.
However, on some compilers such as MSVC, the `-std` flag may reset
defaults for flags that precede it on the command line.  Move the
language standard flag to before all other flags that CMake adds for
other abstractions, and before those added by `add_compile_options`.

`CMAKE_<LANG>_FLAGS` should still precede the language flags though,
because they are meant to be treated as language-wide modifications to
the compiler defaults, similar to `$CC $CFLAGS`.

Fixes: #23860
Fixes: #24170
2022-11-18 11:44:52 -05:00
Brad King
b686b58208 Merge topic 'cmp0141-pch-reuse'
94164ea55e CMP0141: Fix PCH REUSE_FROM when MSVC_DEBUG_INFORMATION_FORMAT is empty

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7914
2022-11-16 08:57:04 -05:00
Brad King
94164ea55e CMP0141: Fix PCH REUSE_FROM when MSVC_DEBUG_INFORMATION_FORMAT is empty
Under the policy's NEW behavior, `[CMAKE_]MSVC_DEBUG_INFORMATION_FORMAT`
may be explicitly set to an empty string to tell CMake not to add any
flags for this abstraction.  In this case, fall back to checking the
language-wide flags as we do in the OLD behavior.

This revises commit 183b9a9eca (CMP0141: Fix PCH REUSE_FROM under policy
NEW behavior, 2022-10-31, v3.25.0-rc3~4^2).

Issue: #24106
2022-11-15 06:57:02 -05:00
Kyle Edwards
09d7f947d6 cmGeneratorExpression: Require cmake instance 2022-11-11 12:29:41 -05:00
Brad King
183b9a9eca CMP0141: Fix PCH REUSE_FROM under policy NEW behavior
Under the CMP0141 NEW behavior added by commit 0e96a20478 (MSVC: Add
abstraction for debug information format, 2022-08-25, v3.25.0-rc1~142^2~1),
the `-Zi` and `-ZI` flags do not appear in `CMAKE_<LANG>_FLAGS_<CONFIG>`
anymore.  Teach the PCH REUSE_FROM implementation to recognize the
`EditAndContinue` and `ProgramDatabase` debug information formats
through the policy's new abstraction.

Fixes: #24106
2022-10-31 12:19:06 -04:00
Brad King
2e65fe92db cmLocalGenerator: Clarify name of local PDB type variable 2022-10-31 12:16:54 -04:00
Brad King
17096aeba8 cmLocalGenerator: Factor out helper to compute MSVC_DEBUG_INFORMATION_FORMAT 2022-10-31 12:16:45 -04:00
Brad King
eebbe36ae6 Merge topic 'Intel-Fortran-warn-errors'
13f3382b1c Intel/IntelLLVM: Fortran has distinct "-Werror"-like flag
ab8a0a106e COMPILE_WARNING_AS_ERROR: Fix internal formatting of options table

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7758
2022-10-10 09:49:46 -04:00
Brad King
ab8a0a106e COMPILE_WARNING_AS_ERROR: Fix internal formatting of options table
In commit 76a08cd253 (COMPILE_WARNING_AS_ERROR: Add options to treat
warnings as errors, 2022-04-21, v3.24.0-rc1~173^2) we formatted the
options table entries as command-line string fragments.  Since they are
part of the `CMAKE_${lang}_COMPILE_OPTIONS_*` tables, they should be
formatted as `;`-separated lists of compiler options.
2022-10-07 10:05:21 -04:00
Glen Chung
0e96a20478 MSVC: Add abstraction for debug information format
Replace our hard-coded default for `/Zi` with a first-class abstraction
to select the debug information format an enumeration of logical
names.  We've long hesitated to do this because the idea of "debug
information format" touches on related concepts on several platforms.
Avoid that scope creep by simply defining an abstraction that applies
only when targeting the MSVC ABI on Windows.

Removing the old default flag requires a policy because existing
projects may rely on string processing to edit them and choose a
runtime library under the old behavior.  Add policy CMP0141 to
provide compatibility.

Fixes: #10189
2022-09-14 09:12:47 -04:00
Brad King
52c95540b7 target_*: Fix cross-directory call backtraces
Record the call-site backtrace, not the current backtrace of the
target's directory.

Fixes: #23873
2022-08-22 15:29:43 -04:00
Andrey Filipenkov
7b2359ac53 Xcode: don't set SKIP_PRECOMPILE_HEADERS when source has no language
Resources that should go into "Copy Bundle Resources" build phase are added as source files but don't have an associated language

Fixes: #23821
2022-08-11 15:26:30 +03:00
Robert Maynard
96bc59b1ca CUDA: Add Device LTO support for nvcc
Fixes #22200
2022-07-22 10:34:45 -04: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
6cc417586e Ninja: Avoid duplicating /DEF: linker flag with MSVC tools
In commit 9a0d5a828a (Ninja: add /DEF: flag to linker call, 2012-03-10,
v2.8.8~22^2~7) the logic should have been added to `GetTargetFlags` in
place of the older logic in that method from commit 7cef36c628 (ENH: add
the ability to generate custom commands for a language that is not
supported by an IDE, 2004-10-21, v2.4.0~2655).

Fixes: #23570
2022-05-31 15:40:58 -04:00
Brad King
39dba8a244 cmLocalGenerator: Adopt AppendModuleDefinitionFlag method
Migrate from `cmCommonTargetGenerator::AddModuleDefinitionFlag`.
2022-05-31 15:40:35 -04:00
Brad King
758756d1ba Merge topic 'ignore-werror-command-arg'
65f7053d6c COMPILE_WARNING_AS_ERROR: Add command-line option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7268
2022-05-19 09:43:53 -04:00
Martin Duffy
65f7053d6c COMPILE_WARNING_AS_ERROR: Add command-line option
Add command-line option `--compile-no-warning-as-error` to ignore value of
`COMPILE_WARNING_AS_ERROR`.

Issue: #19085
2022-05-18 10:30:30 -04:00
Brad King
79b64690d9 Merge topic 'werror-property'
76a08cd253 COMPILE_WARNING_AS_ERROR: Add options to treat warnings as errors

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Michael Hirsch <michael@scivision.dev>
Merge-request: !7187
2022-05-10 10:30:42 -04:00
Martin Duffy
76a08cd253 COMPILE_WARNING_AS_ERROR: Add options to treat warnings as errors
Add `COMPILE_WARNING_AS_ERROR` target property and supporting
`CMAKE_COMPILE_WARNING_AS_ERROR` variable.

`COMPILE_WARNING_AS_ERROR` is initialized by
`CMAKE_COMPILE_WARNING_AS_ERROR`. It is a boolean variable. If it is
true, it expands to a different flag depending on the compiler such that
any warnings at compile will be treated as errors.

Supports compiler ids that I could find a relevant flag for.
2022-05-06 12:14:37 -04:00
Cameron Cawley
33da5824ac OpenWatcom: Allow specifying the runtime library
Add a `CMAKE_WATCOM_RUNTIME_LIBRARY` variable to control the
runtime library selection.  Add policy CMP0136 to switch to
in place of the old hard-coded default flags.

Fixes: #23178
2022-05-06 10:40:58 -04:00
Brad King
1e1b31ac25 Merge topic 'xcode-pch'
476c6a8910 PCH: Fix Xcode non-pch language exclusion
fcf1fcfd0c Tests: Ignore all classes in Xcode internal objc warnings

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7166
2022-04-12 08:10:48 -04:00
Cristian Adam
476c6a8910 PCH: Fix Xcode non-pch language exclusion
Fix a regression caused by commit bbcdac4e5d (PCH: Fix all-language
precompile header support in Xcode, 2021-08-07, v3.22.0-rc1~140^2).

Fixes: #23138
2022-04-11 14:16:33 -04: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
Marc Chevrier
4b55828a9f cmExpandListWithBacktrace: add handling of empty elements. 2022-02-06 14:32:24 +01:00
Brad King
5305d5aa1a Merge topic 'link-interface-direct'
f3ad061858 Add usage requirements to update direct link dependencies
193a999cd5 cmTarget: Add INTERFACE_LINK_LIBRARIES_DIRECT{,_EXCLUDE} backtrace storage
22d5427aa6 cmGeneratorTarget: Add LookupLinkItem option to consider own target name
f3d2eab36a cmGeneratorTarget: Fix link interface caching of partial results
d75ab9d066 cmGeneratorTarget: Clarify CMP0022 logic in ComputeLinkInterfaceLibraries
f3e9e03fe0 cmGeneratorTarget: Simplify CMP0022 warning check
216aa14997 cmGeneratorTarget: Return early from ExpandLinkItems with no items
1bc98371d1 Tests: Remove unnecessary policy setting from ObjectLibrary test
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6886
2022-01-31 10:36:55 -05:00
Brad King
4e8f24e977 PCH: Clear link interface cache when adding PCH object to it
On platforms using `CMAKE_LINK_PCH`, the implementation of
`PRECOMPILE_HEADERS_REUSE_FROM`, when re-using the PCH from one object
library in another, adds a PCH object file to the link interface.
Clear any cached link interface to ensure it is used.
2022-01-29 06:48:11 -05:00
Nick Little
5f8c5657a9 Shorten object name even if still longer than CMAKE_OBJECT_PATH_MAX
In some cases the shortened path may end up working in practice, even if
it is over CMAKE_OBJECT_PATH_MAX, where the original path does not.
If the original path is too long, do the MD5 substitution whenever it
makes the path shorter.  Retain the warning if it is still too long.
2022-01-28 11:12:59 -05:00
NAKAMURA Takumi
780341f360 cmCustomCommand: Track main dependency explicitly
Store the main dependency as the first entry in the dependency list plus
a boolean member indicating its existence.  Note that this slightly
changes existing behavior: the main dependency was previously the last
entry of the dependency list.
2021-12-14 10:48:43 -05:00
Brad King
94a58e502b cmLocalGenerator: Remove unused IncludePathStyle infrastructure
It is unused since commit c564a3e3ff (Ninja: Always compile sources
using absolute paths, 2021-05-19, v3.21.0-rc1~129^2), which left
behind a FIXME comment to eventually remove it.
2021-12-01 11:33:30 -05:00
NAKAMURA Takumi
c46b041a3b cmLocalGenerator: Simplify Add{Custom,Utility}Command 2021-11-18 12:02:38 -05:00
NAKAMURA Takumi
e37511ae7e cmMakefile: Simplify detail:::Add{Custom,Utility}Command
Note 1: `detail::AddCustomCommandToTarget()` resets cc,
since cc is not moved away.

Note 2: In `detail::AddUtilityCommand()`, a few vars are preserved
before using. Their refs will be alive in most cases, but cc might
be destroyed in the future.
2021-11-18 12:02:37 -05:00
NAKAMURA Takumi
9b31a97748 cmCustomCommand: Move constructor arguments to individual setters
Make `cmCustomCommand` have just only default constructor.
Use each setter instead.  This follows the builder pattern.

Introduce `cc::SetOutputs(std::string output)`.
This will be used later, as substitution for `cc::SetOutputs({output})`.
2021-11-18 12:02:37 -05:00
Brad King
129e3c6540 Unity Build: Fix per-config sources in multi-config generators
Single-config generators already support unity builds with per-config
sources because they compute sources using `CMAKE_BUILD_TYPE` as the
configuration.  Each original source is either included in the unity
build source, or not.

Teach multi-config generators to compute the list of sources for
inclusion in unity builds using all configurations.  Previously they
only used the empty string as the configuration.  Each original source
may be included in some configurations, but not others.  Use
preprocessor conditions to guard their inclusion when necessary.

Fixes: #22892
2021-11-11 07:16:11 -05:00
Brad King
53990059da cmLocalGenerator: Add dedicated types to hold unity source info 2021-11-11 06:43:07 -05:00
Brad King
de6e362a88 cmLocalGenerator: Clarify name of method to write unity source include lines 2021-11-10 13:56:05 -05:00
Brad King
3017b3e7d4 cmLocalGenerator: Simplify unity source copy-if-different logic 2021-11-10 13:54:01 -05:00
Brad King
0b56f92576 cmLocalGenerator: De-duplicate unity source file generation 2021-11-10 13:53:57 -05:00
Brad King
4fd2d62613 Merge topic 'cuda_clang_cmp0105'
4707ecbe6f CUDA: Support CMP0105 on Clang
15fde4c420 CUDA: Use local shorthands for variables in Clang device link code
cf7e68087d CUDA: Avoid unnecessary allocation and GetLinkLanguage()
5b0693411e CUDA: Ignore USE_WATCOM_QUOTE for device link rules

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6709
2021-11-09 07:56:21 -05:00
Brad King
9fbbe29138 Merge topic 'nmc-reuse-from'
244550997f PCH: Fixed Ninja Multi-Config and REUSE_FROM for MSVC

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6713
2021-11-09 07:53:19 -05:00
Brad King
95ea17dfd3 Merge topic 'nmc-reuse-from' into release-3.22
244550997f PCH: Fixed Ninja Multi-Config and REUSE_FROM for MSVC

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6713
2021-11-09 07:53:18 -05:00
Brad King
79c21dc9bd Merge topic 'msvc-pch-reuse-config'
95fa27d94d PCH: Fix REUSE_FROM when Debug and RelWithDebInfo configs differ

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6712
2021-11-09 07:52:30 -05:00
Cristian Adam
244550997f PCH: Fixed Ninja Multi-Config and REUSE_FROM for MSVC
The copy_idb_pdb.cmake script would be executed for every configuration
for all configurations.

Debug would still want to get the RelWithDebInfo files, and the other
way around.
2021-11-08 18:16:36 +01:00
Cristian Adam
95fa27d94d PCH: Fix REUSE_FROM when Debug and RelWithDebInfo configs differ
If the Debug configuration contains `/ZI` but the RelWithDebInfo doesn't
then the copy_pdb_idb.cmake script will cause problems due to the fact
that it was common for both configurations but they are incompatible
with each other.
2021-11-08 16:51:18 +01:00
Raul Tambre
cf7e68087d CUDA: Avoid unnecessary allocation and GetLinkLanguage()
There's no reason to allocate the cmNinjaLinkLineDeviceComputer on the heap.
We can also assume the link language as CUDA in cmLocalGenerator::GetDeviceLinkFlags().
2021-11-07 21:28:08 +02:00
Brad King
efc6c23a47 bootstrap: Do not declare cmSystemTools functions that are not implemented
Convert runtime error messages into compile-time errors.
2021-10-27 12:58:02 -04:00
Sean McBride
5ba6e8ac59 Source: Replace most calls to sprintf with snprintf 2021-10-25 18:23:13 -04:00