Commit Graph

208 Commits

Author SHA1 Message Date
Brad King
217f363cac Merge topic 'link-only-targets'
37af6c3311 target_link_libraries: Optionally require only target names
5134f099a3 cmGeneratorTarget: Factor out message about reasons for a missing target
37a25072ea Tests: Rename RunCMake.{CMP0028 => LinkItemValidation}

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6821
2021-12-22 08:52:13 -05:00
Brad King
37af6c3311 target_link_libraries: Optionally require only target names
Optionally verify that items in `LINK_LIBRARIES` and
`INTERFACE_LINK_LIBRARIES` that can be target names are actually target
names.  Add a `LINK_LIBRARIES_ONLY_TARGETS` target property and
corresponding `CMAKE_LINK_LIBRARIES_ONLY_TARGETS` variable to enable
this new check.

Fixes: #22858
2021-12-20 12:14:07 -05:00
Craig Scott
47168b2231 Help: Clarify CMP0126 OLD behavior for FORCE and INTERNAL
Fixes: #23022
2021-12-20 21:24:50 +11:00
Brad King
eaef62ec3b Merge topic 'doc-policy-default'
69b70968bd Help: Suggest CMAKE_POLICY_DEFAULT_CMP0126 in CMP0126 docs
5b1c24255f Help: Suggest CMAKE_POLICY_DEFAULT_CMP0077 in CMP0077 docs
c44636a89b Help: Document more use cases for CMAKE_POLICY_DEFAULT_CMPNNNN

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6756
2021-11-23 09:53:43 -05:00
Brad King
69b70968bd Help: Suggest CMAKE_POLICY_DEFAULT_CMP0126 in CMP0126 docs 2021-11-22 14:57:22 -05:00
Brad King
5b1c24255f Help: Suggest CMAKE_POLICY_DEFAULT_CMP0077 in CMP0077 docs
Issue: #20490
2021-11-22 14:56:17 -05:00
Brad King
648b66a1d3 Merge topic 'cmp0128-fixup'
e47dfce75d CMP0128: Enable/disable extensions if standard same as default

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6723
2021-11-12 09:02:41 -05:00
Raul Tambre
e47dfce75d CMP0128: Enable/disable extensions if standard same as default
This was intended to be part of the initial MR (!6177), but accidentally went
missing when debugging nightly failures on less common systems. Noticed during
!6711 review as the comment about this behaviour didn't match the code.

Documentation for CMP0128 is updated to remove a false case and note the two
cases related to this.

Fixes #22224.
2021-11-11 21:55:04 +02:00
Craig Scott
5b96ff825e Merge topic 'doc-CMP0128'
8371056fbb Help: Correct inaccuracies in wording for CMP0128

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !6711
2021-11-10 05:47:34 -05:00
Craig Scott
8371056fbb Help: Correct inaccuracies in wording for CMP0128 2021-11-09 07:37:09 +11:00
makise-homura
3958ed878f LCC: Add policy CMP0129 regarding interpreting LCC as GNU
Due to MCST LCC compiler identification is now changed to LCC,
there should be a way for old projects to still identify it as GNU,
as it was before.
This commits adds the policy:
CMP0129: Compiler id for MCST LCC compilers is now LCC, not GNU.
This policy controls such a behavior.
OLD behaivior is to treat LCC as GNU, NEW is to treat is as LCC.
2021-10-21 17:24:22 +03:00
Brad King
9f0b52b8e6 Help: Update Sphinx versionadded directives for 3.22 release
Run the script:

    Utilities/Sphinx/update_versions.py --since v3.21.0 --overwrite

Manually select updates that really belong to the 3.22 release, as
against adding documentation for previously-existing entities.
2021-10-07 11:25:51 -04:00
Raul Tambre
4a0485be7f cmStandardLevelResolver: Avoid unnecessary flags, fix unset level logic
The changes are part of CMP0128.

When the standard level is unset:
* Flags are added if extension mode doesn't match the compiler's default.
  Previously logic only worked if LANG_EXTENSIONS was ON. Fixes #22224.
* The full flag is used. Previously CMAKE_LANG_EXTENSION_COMPILE_OPTION was
  used. This was only supported for IAR.

Otherwise:
* Avoid adding flags if not necessary per the detected compiler defaults.
* Fixed check for when the requested standard is older. It now matches the
  nearby comments.

I reworded the fallback comment as its logic was a bit difficult to wrap my
head around.
2021-09-29 22:28:40 +03:00
Daniel Schürmann
059b90a0b4 CMakeDependentOption: Introduce policy CMP0127 for full Condition Syntax
Fixes: #22303
2021-09-10 09:46:55 -04:00
Craig Scott
7b5fa0f7b4 Help: Make policy CMP0126 wording more accurate
The OLD behavior only removes a non-cache variable of the same
name in specific circumstances. The previous wording implied
that it would always occur.

Also add a note about the behavior compared to the analogous
CMP0077 policy, which affects the option() command in a similar
but subtly different way.
2021-07-17 17:18:22 +10:00
Craig Scott
c4bc250f8c Help: Explain policy CMP0125 in more detail 2021-07-17 16:43:25 +10:00
Craig Scott
6d5f74fcd7 Help: Clarify wording of CMP0124 2021-07-17 16:43:25 +10:00
Marc Chevrier
16208ac113 CMP0126: Add control for warnings
Fixes: #22353
2021-06-29 13:36:28 +02:00
Ben Boeckel
894645d4a6 Help/CMP0102: mention the varible that controls CMP0102 warnings
This was missed in the review of !4150, but was noticed during
discussion of #22353.
2021-06-28 08:17:25 -04:00
Marc Chevrier
d96eb55282 set(CACHE): do not remove normal variable
Fixes: #22038
2021-05-20 17:50:13 +02:00
Marc Chevrier
08db1341a6 find_*: ensure consistent behavior for cache variables
Fixes: #22121
2021-05-12 11:11:56 +02:00
Josef Angstenberger
7072d83772 Help: Fix typos and spelling in documentation 2021-05-07 17:00:17 +02:00
Marc Chevrier
46896d98bb foreach(): loop variables are only available in the loop scope
Fixes: #20553
2021-04-28 19:44:25 +02:00
Lingkai Dong
c4941b7e66 ARMClang: Do not automatically add cpu/arch compile or link options
The compile options `--march=<arch>` and `--mcpu=<cpu>` and the
link option `--cpu=<cpu>` are automatically added by CMake based
on `CMAKE_SYSTEM_PROCESSOR` or `CMAKE_SYSTEM_ARCH`. But this is not
sufficient, because armclang also supports enabling or disabling
features using `+<feature>`:

    -mcpu=<name>[+[no]<feature>+...]

For example:

    -mcpu=cortex-a57+nocrypto+nofp+nosimd+crc

(Reference: https://developer.arm.com/documentation/dui0774/k/Compiler-Command-line-Options/-mcpu?lang=en)

The problem is, even if a project adds a flag with features it needs,
CMake still adds flags, resulting in code that is compiled with wrong
CPU features and unable to run.

Add policy `CMP0123` to not automatically add compile or link options,
and let projects set them instead.

Co-Author: Brad King <brad.king@kitware.com>
Fixes: #21173
2021-04-27 14:03:15 -04:00
Robert Maynard
e4ff2b51b9 Help: Demonstrate using set_target_properties with CUDA architectures
A common anti-pattern is to copy from the `CUDA_ARCHITECTURES` documentation.
If at any point the user tries to simplify by changin `set_property` to `set_target_properties` the code breaks.

To better train users, provide and example of how to set multiple
CUDA architectures with `set_target_properties`.
2021-04-20 13:25:53 -04:00
Marc Chevrier
1d8e3a1e77 UseSWIG: Use standard library name conventions for csharp language
Fixes: #21542
2021-03-26 16:27:18 +01:00
Brad King
8ebd5521f7 Merge topic 'fix-CMP0118-NEW'
17eb610a31 Help: Document CMP0118 requirement for boolean values
06feb845aa CMP0118: Fix NEW behavior when looking up target sources

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5921
2021-03-19 11:17:20 -04:00
Brad King
17eb610a31 Help: Document CMP0118 requirement for boolean values 2021-03-18 10:00:02 -04:00
Brad King
ab3485d15b Merge topic 'autogen-cmp0116-fix'
339dbc901f Help: Note that CMP0116 is recorded at the time of CC creation
e3740e020e Tests: Test Qt autogen target with CMP0116 set to WARN
cf34011ce7 Tests: Test per-CC behavior of CMP0116
3a95503512 Ninja: Use CMP0116 status recorded at time of custom command's creation
f01f10e8fb cmCustomCommand: Record value of CMP0116 at time of creation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5848
2021-02-24 09:44:59 -05:00
Kyle Edwards
339dbc901f Help: Note that CMP0116 is recorded at the time of CC creation 2021-02-23 09:17:12 -05:00
Ben Boeckel
79eaa908dc cmListCommand: add a policy for failing on invalid indicies 2021-02-18 08:30:55 -05:00
Brad King
a30d096c85 Help: Update Sphinx versionadded directives for 3.20 release
Run the script:

    Utilities/Sphinx/update_versions.py --since v3.19.0 --overwrite

Manually restore the 3.20 version for `cmake_path`, which was originally
part of 3.19 but reverted and restored in 3.20.
2021-02-10 08:18:12 -05:00
Brad King
5dd356cefc Help: Convert some genex names to explicit cross-references
Since commit c2dc7e0f53 (Help: Convert genex documentation to sphinx
domain objects, 2021-01-15) we can use `:genex:` cross-references to
link to named generator expressions.  Update some places to do this.

This is meant to demonstrate the capability, not as a comprehensive
sweep.
2021-02-05 16:05:25 -05:00
Brad King
c4feb00aa5 Merge topic 'update_cmp112'
cf0c71dae3 Document CMP0112 covers $<TARGET_FILE_NAME,tgt>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5582
2020-12-08 10:20:12 -05:00
Robert Maynard
cf0c71dae3 Document CMP0112 covers $<TARGET_FILE_NAME,tgt>
Fixes #21559
2020-12-07 09:50:39 -05:00
Brad King
da7ad7997e WriteCompilerDetectionHeader: Add policy to remove module
See justification in the policy documentation.

Closes: #17842
2020-12-05 21:57:08 +11:00
Brad King
48aac247e9 Compile with explicit language flag when source LANGUAGE property is set
This change was originally made by commit 74b1c9fc8e (Explicitly specify
language flag when source LANGUAGE property is set, 2020-06-01,
v3.19.0-rc1~722^2), but it was reverted by commit 30aa715fac (Revert
"specify language flag when source LANGUAGE property is set",
2020-11-19) to restore compatibility with pre-3.19 behavior.

Implement the change again, but add policy CMP0119 to make this change
while preserving compatibility with existing projects.

Note that the `Compiler/{Clang,Intel,MSVC}-CXX` modules do not need to
specify `-TP` for their MSVC-like variants because we already use the
flag in `CMAKE_CXX_COMPILE_OBJECT`.  Similarly for `Compiler/XL-CXX`
and `Platform/Windows-Embarcadero`.

Note also that this does not seem possible to implement for XL C.
Even with `-qsourcetype=c`, `xlc` complains about an unknown suffix:
`1501-218 (W) file /.../AltExtC.zzz contains an incorrect file suffix`.
It returns non-zero even with `-qsuppress=1501-218`.

Co-Author: Robert Maynard <robert.maynard@kitware.com>
Fixes: #14516, #20716
2020-12-02 11:39:11 -05:00
Deniz Bahadir
0eb30f175e GENERATED prop: Introducing policy CMP0118 and its documentation
Note: This is currently only defining the CMP0118 policy and providing
its documentation, however, the implementation is still not using it.
2020-11-24 17:41:02 +01:00
Brad King
c00a6d3967 MSVC: Do not add /GR to CMAKE_CXX_FLAGS by default
The `/GR` flag has been on by default since MSVC cl 14.0 from VS 2005.
Remove it from the default flags to make it easier for projects to pass
`/GR-` themselves to turn it off.

Projects may be using string processing to replace `/GR` with another
flag, so we cannot simply drop it.  Add a policy to drop it in a
compatible way.

Fixes: #21428
2020-11-13 11:46:23 -05:00
Craig Scott
394a5b71b0 Merge topic 'docs-cleanup-3.19'
95c14579f2 Help: Cleanup typos and grammar for the 3.19 release

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5419
2020-10-26 07:16:03 -04:00
Craig Scott
95c14579f2 Help: Cleanup typos and grammar for the 3.19 release 2020-10-24 22:58:42 +11:00
Brad King
860e40de6b Merge topic 'doc-CMP0111'
5c3a91c808 CMP0111: Clarify that the new error is on a missing property setting

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex Reinking <alex_reinking@berkeley.edu>
Merge-request: !5385
2020-10-19 10:23:50 -04:00
Brad King
5c3a91c808 CMP0111: Clarify that the new error is on a missing property setting
The previous wording could be confused with the file missing on disk.
2020-10-16 08:26:00 -04:00
Kyle Edwards
146e1e6ba1 Ninja: Transform DEPFILEs with policy CMP0116
Fixes: #21267
2020-10-13 10:19:46 -04:00
Kyle Edwards
fd50a75fa0 CMP0115: Require source file extensions to be explicit 2020-10-13 09:46:54 -04:00
Brad King
e1ab55b4ca Help: Update Sphinx versionadded directives for 3.19 release
Run the script:

    Utilities/Sphinx/update_versions.py --since v3.18.0 --overwrite
2020-10-08 09:30:26 -04:00
Brad King
b4fc4da903 ExternalProject: Add policy CMP0114 to refine step target dependencies
`ExternalProject_Add_StepTargets` and `INDEPENDENT_STEP_TARGETS` have
some limitations and lack some sanity checks.  They can cause confusing
build systems to be generated.  The basic problems are:

* The notion of step independence is attached to the step target
  rather than the step itself.

* The custom commands implementing the steps are duplicated in the
  step targets and the primary targets.  This can cause races.
  It is also incompatible with the Xcode "new build system".

Fix this by introducing policy CMP0114 to change the way step target
dependencies are handled.  Define independence from external
dependencies as a property of each individual step regardless of whether
there is a target for it.  Add dependencies among the primary target and
the step targets such that each custom command only appears in one
target.  When some steps are disconnected from the primary target, add
step targets for the steps commonly depended upon so that there is a
place to hold their custom commands uniquely.

Fixes: #18663
2020-09-14 10:48:16 -04: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
Robert Maynard
f14b390198 GenEx: Remove unneeded dependencies from target info queries
Only generate a graph dependency between a custom command and
a target when the custom command queries for the file path
of an artifact of the target.

This makes generator expressions such as `TARGET_FILE_DIR`
behave the same way as `TARGET_PROPERTY` which never generated
a graph dependency.
2020-09-01 09:25:19 -04:00
Raul Tambre
359c500a24 cmTarget: Raise error if imported target location is not set
Previously we would synthesize <TARGET_NAME>-NOTFOUND as the location. This
would then end up on the link line and cause build failures.
Policy CMP0110 is added to control this behaviour.

Fixes #19080, #19943.
2020-08-21 08:38:39 -04:00