Commit Graph

223 Commits

Author SHA1 Message Date
Orkun Tokdemir
7bf4e30090 Autogen: Default AUTOGEN_USE_SYSTEM_INCLUDE to ON if it is not set
Add policy CMP0151 to preserve the old behavior by default.
2023-05-03 09:03:46 -04:00
Chris Wright
550f63447d
ExternalProject/FetchContent: Support relative remote URLs
Teach `ExternalProject_Add` and `FetchContent_Declare` to resolve
relative remote URLs provided via `GIT_REPOSITORY`.  Add policy
CMP0150 to maintain compatibility.

Fixes: #24211
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
2023-04-26 16:30:36 +08:00
Brad King
f90c8ab54e VS: Select latest available Windows SDK version by default
Add policy `CMP0149` to stop preferring SDKs exactly matching
`CMAKE_SYSTEM_VERSION` over the latest SDK.

Fixes: #16202
2023-04-05 12:06:22 -04:00
Brad King
a4c5b91f80 FindPython{Interp,Libs}: Add policy to remove these modules
The `FindPythonInterp` and `FindPythonLibs` modules have been deprecated
since CMake 3.12.  Add a policy to pretend they do not exist in order to
encourage projects to port to `FindPython` or `FindPython{2,3}`.
2023-03-30 12:05:09 -04:00
Brad King
d6353e74b4 VS: Add policy to build custom commands concurrently
In commit 33c15ae2b9 (VS: Build custom commands concurrently when
possible, 2023-01-19, v3.26.0-rc1~56^2) we added `BuildInParallel` to
custom commands in `.vcxproj` files, but that had to be reverted by
commit abb1c12162 (VS: Revert "Build custom commands concurrently when
possible", 2023-03-07, v3.26.0-rc6~3^2) because some projects may have
custom commands that accidentally rely on serial execution in MSBuild.

Add a policy to use `BuildInParallel` for custom commands in projects
that have been updated to set the policy to `NEW`.

Fixes: #18405
2023-03-12 07:51:58 -04:00
Brad King
2c146a7fc5 FindCUDA: Add policy to remove this module
The `FindCUDA` module has been deprecated since CMake 3.10.
Add a policy to pretend it doesn't exist in order to encourage
projects to port away from it.
2023-03-09 07:39:36 -05:00
Brad King
2e469212c8 Dart,FindDart: Add policy to remove these modules
These modules and the "DART" tool they support have long been replaced
by CTest.
2023-02-28 08:43:45 -05:00
Brad King
df9c4b1872 find_package: Use <PACKAGENAME>_ROOT variables as search prefixes
Extend commit eb35d8884b (find_package: Use PackageName_ROOT variables
as search prefixes, 2018-03-15, v3.12.0-rc1~349^2) to also check
upper-case `<PACKAGENAME>_ROOT` variables.  Add policy `CMP0144` to
enable the behavior in a compatible way.

Fixes: #24403
2023-02-23 09:15:14 -05:00
Kyle Edwards
480b363724 cmCustomCommand: Refactor custom command-specific policy values
Many custom commands are created by CMake itself rather than by
the user. These custom commands should always have their policies
set to NEW, and user-created custom commands should have their
policy values set only from the state snapshot. In addition, we
want to genericize the mechanism of recording a policy at the time
of custom command creation.

Add a CM_FOR_EACH_CUSTOM_COMMAND_POLICY macro to genericize
custom command policies. Use this to define all custom command
policies. Make all such policies NEW instead of WARN by default.
Remove individual policy modifier methods and add a single method
that records relevant values from a cmStateSnapshot. Remove the
no longer needed explicit policy settings from synthesized custom
commands.
2023-02-06 15:04:16 -05:00
Juan Ramos
d3acd22380 USE_FOLDERS: Treat as on by default
Add a policy to treat the `USE_FOLDERS` global property as ON by default
if it is not set.

Fixes: #21695
2022-11-08 09:32:18 -05:00
Mikko Sivulainen
d4cc39842e Xcode: Do not append per-config suffixes to library search paths
Add policy `CMP0142` to remove the automatic addition of the
`$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` suffix in a compatible way.

Fixes: #21757
2022-09-15 10:27:23 -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
Marc Chevrier
838a5fae23 return(): Propagate variables to result scope
Fixes: #23871
2022-09-03 23:10:01 +02:00
Brad King
ec08bc1752 CheckIPOSupported: Compile check using flags of calling project
Forward `CMAKE_<LANG>_FLAGS` and `CMAKE_<LANG>_FLAGS_DEBUG` from the
calling project into the test project.  The set of flags may affect the
availability of IPO support.  Since this may change the result of the
check for existing projects, add a policy for compatibility.

This was discovered after commit 5fcadc481e (MSVC: Default to -ZI
instead of /Zi for x86 and x64, 2022-05-24) introduced policy CMP0138 to
switch our default for MSVC's debug info flag.  The `-ZI` flag is
incompatible with the `-GL` flag used for IPO, so CMP0138 was reverted
pending future work on an alternative solution.  Re-use the CMP0138
policy number for this change to CheckIPOSupported instead.

Fixes: #23607
2022-06-10 09:12:43 -04:00
Brad King
7d73e88d3a MSVC: Revert "Default to -ZI instead of /Zi for x86 and x64"
Revert commit 5fcadc481e (MSVC: Default to -ZI instead of /Zi for x86
and x64, 2022-05-24).  The `-ZI` flag is incompatible with the `-GL`
flag used for IPO, and so is not an unconditionally better default.
Revert the change pending future design of a first-class setting for
MSVC debug info format that can be automatically reconciled with IPO
settings.

That commit introduced policy CMP0138, but we already have later policy
numbers used too.  Leave placeholder text to avoid policy renumbering.

Issue: #23607, #10189
2022-06-09 12:24:33 -04:00
Marc Chevrier
be4b9e10af if command: Add PATH_EQUAL operator 2022-06-03 19:31:36 +02:00
Glen Chung
5fcadc481e MSVC: Default to -ZI instead of /Zi for x86 and x64
Add a policy for compatibility.

For more information, see [1].

[1] https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=msvc-170

Fixes: #10189
2022-05-26 09:06:01 -04:00
Brad King
4843a37676 try_compile: Propagate platform variables in project-mode too
Add policy CMP0137 to propagate both our builtin variables and those
listed by `CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` to `try_compile`
whole-project builds.

Inspired-by: Alexander Neumann <Alexander.Neumann@hamburg.de>
Fixes: #23219
2022-05-16 10:39:42 -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
Kasper Laudrup
a283e58b51 ExternalProject: Add DOWNLOAD_EXTRACT_TIMESTAMP option and policy
Add the option to keep the current filestamps when extracting an
archive in ExternalProject_Add.

Enabling this option makes the behavior consistent with how
ExternalProject_Add is used when checking out code from revision
control instead of an archive.

Fixes: #22746
2022-05-05 09:01:54 +10:00
Marc Chevrier
8d7e80cf3d find_* commands: add control over Windows registry views
Fixes: #22775
2022-04-29 22:00:02 +02:00
Brad King
b760828d3f CPack/DMG: Do not use CPACK_RESOURCE_FILE_LICENSE for SLA by default
Since macOS 12.0 deprecated the tools needed to attach a SLA to a
`.dmg`, we should no longer do this by default.  Add a policy to
change the default to off.

Fixes: #22978
2022-04-14 10:14:58 -04:00
Craig Scott
05e510bf0b CMP0132: Don't set compiler environment variables on first run
When running CMake for the first time in a build tree, for some
generators CMake would set compiler environment variables
like CC, CXX, etc. when the corresponding language is enabled.
That behavior was never documented and can result in different
behavior between the first and subsequent runs. Add a policy
to no longer set those environment variables.

Fixes: #21378
2022-03-29 09:42:59 -04:00
Brad King
cf312a2e54 LINK_LIBRARIES: Add support for LINK_ONLY genex
Previously we always used content guarded by `$<LINK_ONLY:...>`
in `LINK_LIBRARIES`, even when evaluating for non-linking usage
requirements.  Add a policy to honor `LINK_ONLY` in `LINK_LIBRARIES`
the same way we already do in `INTERFACE_LINK_LIBRARIES`.
2022-03-24 08:23:55 -04:00
Brad King
30313aa721 while: diagnose errors during condition evaluation
Add a policy to diagnose condition errors in a compatible way.

Fixes: #23296
2022-03-04 13:55:12 -05: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
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
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
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
Marc Chevrier
1d8e3a1e77 UseSWIG: Use standard library name conventions for csharp language
Fixes: #21542
2021-03-26 16:27:18 +01:00
Ben Boeckel
79eaa908dc cmListCommand: add a policy for failing on invalid indicies 2021-02-18 08:30:55 -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
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
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
Kitware Robot
bdca8b01d2 Modernize: Use #pragma once in all header files
#pragma once is a widely supported compiler pragma, even though it is
not part of the C++ standard. Many of the issues keeping #pragma once
from being standardized (distributed filesystems, build farms, hard
links, etc.) do not apply to CMake - it is easy to build CMake on a
single machine. CMake also does not install any header files which can
be consumed by other projects (though cmCPluginAPI.h has been
deliberately omitted from this conversion in case anyone is still using
it.) Finally, #pragma once has been required to build CMake since at
least August 2017 (7f29bbe6 enabled server mode unconditionally, which
had been using #pragma once since September 2016 (b13d3e0d)). The fact
that we now require C++11 filters out old compilers, and it is unlikely
that there is a compiler which supports C++11 but does not support
#pragma once.
2020-09-03 09:30:21 -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
Deniz Bahadir
a20987732b add_test: Allow special characters in test name (w/ policy CMP0110)
Restore the change from commit f84af8e270 (add_test: Allow special
characters in test name, 2020-05-16, v3.18.0-rc1~142^2) that had to be
reverted by commit f84af8e270 (add_test: Allow special characters in
test name, 2020-05-16, v3.18.0-rc1~142^2) for compatibility.

Add policy CMP0110 to make the change in a compatible way.
Also, support even more characters than before by generating the
test scripts using bracket arguments around the test names.

Fixes: #19391
Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
2020-08-12 10:44:07 -04:00
Brad King
5845c218d7 Deprecate compatibility with CMake versions older than 2.8.12
Issue a deprecation warning on calls to `cmake_minimum_required` or
`cmake_policy` that set policies based on versions older than 2.8.12.
Note that the effective policy version includes `...<max>` treatment.
This is important in combination with commit ca24b70d31 (Export: Specify
a policy range in exported files, 2020-05-16, v3.18.0-rc1~133^2).
2020-06-18 09:52:05 -04:00
Brad King
9d45a8be08 find_program: Find programs that are executable but not readable
This fix was first made by commit 86e6349ef7 (find_program: Find
programs that are executable but not readable, 2020-04-04,
v3.18.0-rc1~372^2) but was reverted for compatibility.  Re-introduce it
with a policy for compatibility.

Fixes: #10468
2020-06-15 11:58:47 -04:00