Commit Graph

77 Commits

Author SHA1 Message Date
Nils Gladitz 188a1f236e If: Introduce policy CMP0054 - don't dereference quoted variables in if() 2014-09-11 21:23:17 +02:00
Ben Boeckel 25102efc1d EVIS: Add policy CMP0053
This policy switches between the old EVIS parser and the new, faster
parser.
2014-05-08 13:24:49 -04:00
Stephen Kelly 783bce295b Export: Disallow exported interface includes in src/build tree (#14592).
Allow directories in the source tree or build tree only if the
install tree is a subdirectory of the source tree or build tree,
as appropriate.

Re-use the test files in the RunCMake.include_directories test
to run in multiple scenarios.  Bump the required CMake version
in the test to 3.0 to ensure that the new policy warnings are
emitted correctly.
2014-04-09 10:38:49 +02:00
Stephen Kelly 5702e10677 cmTarget: Include TARGET_OBJECTS genex in target SOURCES property.
Add policy CMP0051 to control this behavior.
2014-04-02 23:12:56 +02:00
Stephen Kelly f2eee72fac add_custom_command: Disallow use of SOURCE signatures.
Add CMP0050 to control this behavior.
2014-02-12 11:19:27 -05:00
Stephen Kelly c248a437c4 Add policy CMP0049 to avoid variable expansion in source lists 2014-02-12 11:17:38 -05:00
Brad King 101057b500 Drop tweak version component from CMake Policies
Since commit v2.8.2~105^2~2 (Teach CMake Policies about tweak version
component, 2010-04-23), cmPolicies has known how to handle a policy
introduced in a tweak version.  This was done back when we introduced
policies with the current development date version and later updated it
to the release version.  Now we always introduce policies using the next
expected release version and explicitly set the policy to test the NEW
behavior.

CMake Policies (or any other features) should never be introduced in a
tweak (bugfix) release, so drop the infrastructure that allows this.
2014-02-04 16:14:26 -05:00
Brad King 7e142c5ac2 project: Manage VERSION variables
Teach the project() command to set variables

  {PROJECT,<PROJECT-NAME>}_VERSION{,_MAJOR,_MINOR,_PATCH,_TWEAK}

holding the project version number and its components.  Add project()
command option "VERSION" to specify the version explicitly, and default
to the empty string when it is not given.

Since this clears variables when no VERSION is given, this may change
behavior for existing projects that set the version variables themselves
prior to calling project().  Add policy CMP0048 for compatibility.

Suggested-by: Alex Neundorf <neundorf@kde.org>
2014-01-29 09:45:18 -05:00
Stephen Kelly e00db59d6c QNX: Introduce QCC compiler id for that QNX platform compiler.
Introduce policy CMP0047 to control resetting the id for
compatibility.

De-duplicate content in the QNX platform file by including the GNU
one. QNX is a form of GNU platform.

Do not clear CMAKE_SHARED_LIBRARY_${lang}_FLAGS variables.  They
are populated again later by the Compiler/GNU.cmake file anyway.

Modify the CMAKE_CXX_COMPILE_OBJECT variable only when the QCC
compiler id is in use, and the language is CXX.  Use the QNX
recommended flag for QCC instead of the gcc compatible -x flag.

Populate new module files to handle system includes and depfiles
when using the QCC compiler.

Remove code which unsets the system include and depfiles related
variables.  When a GNU driver is used instead of the QCC one, the
appropriate flags will be used.  These variables were previously
cleared for lowest-common-denominator compatibility with both
drivers.
2014-01-22 08:47:32 -05:00
Nils Gladitz 0bf6f13b1d AddDependencies: new policy requires dependencies to exist
Added new policy CMP0046 which requires dependencies added by
add_dependencies() to actually exist.
2014-01-12 12:58:04 +01:00
Stephen Kelly 73e93400e2 get_target_property: Error on non-existent target.
Introduce policy CMP0045 to control this behavior.
2014-01-08 16:41:34 +01:00
Stephen Kelly 6aabb6a62b Genex: Use case-sensitive comparison for COMPILER_ID. 2014-01-08 16:41:34 +01:00
Stephen Kelly 5bb53f6b73 cmTarget: Deprecate COMPILE_DEFINITIONS_ properties with a policy. 2014-01-08 16:41:34 +01:00
Clinton Stimpson d25ad482e9 OS X: Add CMP0042 to enable MACOSX_RPATH by default
Also adding documentation for CMAKE_MACOSX_RPATH, and improving
documentation for MACOSX_RPATH.
2014-01-02 13:41:49 -05:00
Stephen Kelly 5838aba1aa Export: Report error on relative include with genex.
Diagnostics which check the sanity of exported include paths
previously skipped over any path containing a generator expression.

Introduce a policy to issue an error message in such cases.

The export files created in the OLD behavior are not usable, because
they contain relative paths or paths to the source or build location
which are not suitable for use on installation. CMake will report an
error on import.
2013-11-26 13:01:55 +01:00
Nils Gladitz a02f3d2de0 Add policy CMP0040 to disallow custom commands on missing targets 2013-11-21 09:24:08 -05:00
Nils Gladitz 3900fcf4a8 CMP0037: Extend policy to reserved names and custom targets
Teach add_custom_target to check the policy too.  Extend the policy to
disallow reserved target names that we use for builtin targets like
"all".

Extend the RunCMake.CMP0037 test to cover these cases.
2013-11-19 09:44:22 -05:00
Stephen Kelly 596b2a8c08 Disallow linking to utility targets (#13902). 2013-11-07 11:06:40 +01:00
Stephen Kelly 301bb5cdda Disallow link-to-self (#13947). 2013-11-07 11:06:39 +01:00
Stephen Kelly 05f5fde0eb Disallow invalid target names (#13140)
Exclude Borland and NMake from the CMP0037 test. They do not accept
the colon in a target name.
2013-11-07 11:06:39 +01:00
Brad King 6c9194488a Add policy CMP0036 to disallow build_name 2013-10-22 09:09:53 -04:00
Brad King 3969bb23aa Add policy CMP0035 to disallow variable_requires 2013-10-22 09:09:52 -04:00
Brad King 178b9af186 Add policy CMP0034 to disallow utility_source 2013-10-22 09:09:52 -04:00
Brad King 248d1dc057 Add policy CMP0033 to disallow export_library_dependencies 2013-10-22 09:09:52 -04:00
Brad King 6865c8fe05 Add policy CMP0032 to disallow output_required_files 2013-10-22 09:09:52 -04:00
Brad King aa76518f8b Add policy CMP0031 to disallow load_command 2013-10-22 09:09:52 -04:00
Brad King 97268cf5b7 Add policy CMP0030 to disallow use_mangled_mesa 2013-10-22 09:09:51 -04:00
Brad King 9f64fbf5b5 Add policy CMP0029 to disallow subdir_depends 2013-10-22 09:09:51 -04:00
Stephen Kelly f063c45589 Consider targets with double colons to be IMPORTED or ALIAS targets.
Introduce a policy to control the behavior.

The AliasTargets unit test already tests that using a
double-semicolon in the name is not an error. Change the ExportImport
test to use a namespace with a double-semicolon too.
2013-10-21 15:56:31 +02:00
Stephen Kelly 70ae6dfd92 Handle genexes when evaluating INTERFACE_INCLUDE_DIRECTORIES errors. 2013-10-18 10:11:49 -04:00
Brad King 5cdaef7ee9 Drop builtin policy "full" documentation
The full policy documentation was moved to Help/policy/*.rst by commit
f051814e (Convert builtin help to reStructuredText source files,
2013-10-15).  We no longer need the builtin string literals.

In commit 87cc62ca (Drop "full" documentation output types, 2013-09-13)
we dropped code using the LongDescription field of policy definitions.
We need to follow it up with a change similar to commit 399e9c46 (Drop
builtin property documentation, 2013-09-16) to remove the policy
documentation.  Do that now.  Keep the short description as it is used
in policy error and warning messages.
2013-10-17 15:00:20 -04:00
Brad King 87cc62cab9 Drop "full" documentation output types
We will no longer support full documentation generation from executables
and will instead generate documentation with other tools.  Disable (with
a warning left behind) the command-line options:

 --copyright
 --help-compatcommands
 --help-full
 --help-html
 --help-man

Drop supporting code.  Drop manual sections generation from executables.
Remove internal documentation construction APIs.  Drop unused sections
See Also, Author, Copyright, Compat Commands, Custom Modules.
2013-10-15 14:12:49 -04:00
Stephen Kelly e4e5b28c27 cmTarget: Deprecate the LOCATION target property with a policy.
The final location and name of a build-target is not determined
until generate-time. However, reading the LOCATION property from
a target is currently allowed at configure time. Apart from creating
possibly-erroneous results, this has an impact on the implementation
of cmake itself, and prevents some major cleanups from being made.

Disallow reading LOCATION from build-targets with a policy. Port some
existing uses of it in CMake itself to use the TARGET_FILE generator
expression.
2013-10-11 21:17:27 +02:00
Brad King aa53ee57bb Add policy CMP0025 for Apple Clang compiler id compatibility
The parent commit introduced a separate "AppleClang" compiler id for
Apple's Clang distribution.  Add a policy in order to support projects
that expect this compiler's id to be just "Clang".  When the policy is
OLD or not set, map AppleClang back to Clang.  Continue to use the
AppleClang id internally while enabling the language, but set the
CMAKE_<LANG>_COMPILER_ID after project() or enable_language() to the
compatible value for use by project code.
2013-10-07 20:12:46 -04:00
Stephen Kelly 904ff9fe59 export: Add policy CMP0024 to disallow include() of export files
Currently, export() is executed at configure-time.

One problem with this is that certain exported properties like
the link interface may not be complete at the point the export() is
encountered leading to an incorrect or incomplete exported
representation. Additionally, the generated IMPORTED_LOCATION
property may even be incorrect if commands following the export()
have an effect on it.

Another problem is that it requires the C++ implementation of cmake
to be capable of computing the exported information at configure time.
This is a limitation on the cleanup and maintenance of the code. At
some point in the future, this limitation will be dropped and more
implementation will be moved from cmTarget to cmGeneratorTarget.
2013-10-07 19:57:06 -04:00
Stephen Kelly b655865bbf target_link_libraries: Add PUBLIC/PRIVATE/INTERFACE keyword signature
Add a new signature to help populate INTERFACE_LINK_LIBRARIES and
LINK_LIBRARIES cleanly in a single call.  Add policy CMP0023 to control
whether the keyword signatures can be mixed with uses of the plain
signatures on the same target.
2013-07-24 11:52:44 -04:00
Stephen Kelly d0a76ea07c Introduce the INTERFACE_LINK_LIBRARIES property.
This property replaces the properties which
match (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?, and is enabled
for IMPORTED targets, and for non-IMPORTED targets only with a policy.

For static libraries, the INTERFACE_LINK_LIBRARIES property is
also used as the source of transitive usage requirements content.
Static libraries still require users to link to all entries in
their LINK_LIBRARIES, but usage requirements such as INCLUDE_DIRECTORIES
COMPILE_DEFINITIONS and COMPILE_OPTIONS can be restricted to only
certain interface libraries.

Because the INTERFACE_LINK_LIBRARIES property is populated unconditionally,
we need to compare the evaluated result of it with the link implementation
to determine whether to issue the policy warning for static libraries. For
shared libraries, the policy warning is issued if the contents of
the INTERFACE_LINK_LIBRARIES property differs from the contents of the
relevant config-specific old LINK_INTERFACE_LIBRARIES property.
2013-07-08 22:39:09 +02:00
Stephen Kelly eabefa8b02 Error on relative path in INCLUDE_DIRECTORIES target property.
Add policy CMP0021 to preserve existing behavior in projects expecting
it from earlier CMake versions.
2013-05-21 14:59:17 -04:00
Stephen Kelly e3b5eb6b23 Automatically link to the qtmain library when linking to QtCore.
When using QAxServer, ensure that the qtmain library is excluded
by reporting an error at CMake time if it is not.
2013-01-23 14:15:41 -05:00
Brad King 711b63f7e0 Add policy CMP0019 to skip include/link variable re-expansion
Historically CMake has always expanded ${} variable references in the
values given to include_directories(), link_directories(), and
link_libraries().  This has been unnecessary since general ${}
evaluation syntax was added to the language a LONG time ago, but has
remained for compatibility with VERY early CMake versions.

For a long time the re-expansion was a lightweight operation because it
was only processed once at the directory level and the fast-path of
cmMakefile::ExpandVariablesInString was usually taken because values did
not have any '$' in them.  Then commit d899eb71 (Call
ExpandVariablesInString for each target's INCLUDE_DIRECTORIES,
2012-02-22) made the operation a bit heavier because the expansion is
now needed on a per-target basis.  In the future we will support
generator expressions in INCLUDE_DIRECTORIES with $<> syntax, so the
fast-path in cmMakefile::ExpandVariablesInString will no longer be taken
and re-expansion will be very expensive.

Add policy CMP0019 to skip the re-expansion altogether in NEW behavior.
In OLD behavior perform the expansion but improve the fast-path
heuristic to match ${} but not $<>.  If the policy is not set then warn
if expansion actually does anything.  We expect this to be encountered
very rarely in practice.
2012-12-07 09:51:19 -05:00
Stephen Kelly bd34963002 Refactor generation of shared library flags
CMAKE_SHARED_LIBRARY_<lang>_FLAGS has flags on various platforms for a
variety of purposes that are correlated with shared libraries but not
exclusive to them.  Refactor generation of these flags to use new
purpose-specific platform variables

  CMAKE_<lang>_COMPILE_OPTIONS_DLL
  CMAKE_<lang>_COMPILE_OPTIONS_PIC
  CMAKE_<lang>_COMPILE_OPTIONS_PIE

Activate the DLL flags specifically for shared libraries.  Add a new
POSITION_INDEPENDENT_CODE target property to activate PIC/PIE flags, and
default to true for shared libraries to preserve default behavior.
Initialize the new property from CMAKE_POSITION_INDEPENDENT_CODE to
allow easy global configuration in projects.

Although the default behavior is unchanged by this refactoring, the new
approach ignores CMAKE_SHARED_LIBRARY_<lang>_FLAGS completely.  We must
leave it set in case projects reference the value.  Furthermore, if a
project modifies CMAKE_SHARED_LIBRARY_<lang>_FLAGS it expects the new
value to be used.  Add policy CMP0018 to handle compatibility with
projects that modify this platform variable.

Add a PositionIndependentCode test on platforms where we can get
meaningful results.
2012-06-12 15:38:48 -04:00
Yury G. Kudryashov 477459010f doxygen: fix some comments in cmPolicies.h 2012-03-01 02:33:12 +04:00
Alex Neundorf db44848f44 Prefer files from CMAKE_ROOT when including from CMAKE_ROOT
This patch makes include() and find_package() prefer cmake files
located in CMAKE_ROOT over those in CMAKE_MODULE_PATH.
This makes sure that the including file gets that file included
which it expects, i.e. the one from cmake with which it was tested.
It only changes behaviour when such an included file exists both
in CMAKE_MODULE_PATH and in CMAKE_ROOT.
This comes together with a new policy CMP0017, with default
behaviour it behaves as it always did, but warns.
With NEW behaviour it includes the file from CMAKE_ROOT
instead from CMAKE_MODULE_PATH. This fixes (if CMP0017 is set)
building KDE 4.5 with cmake >= 2.8.3.
Also a basic test for this policy in included.
2011-01-04 08:06:20 -05:00
Brad King a364daf1fd Allow users to specify defaults for unset policies
Check CMAKE_POLICY_DEFAULT_CMP<NNNN> for a default when policy CMP<NNNN>
would otherwise be left unset.  This allows users to set policies on the
command line when the project does not set them.  One may do this to
quiet warnings or test whether a project will build with new behavior
without modifying code.  There may also be cases when users want to
build an existing project release using new behavior for policies
unknown to the project at the time of the release.
2011-01-04 07:46:10 -05:00
Alex Neundorf 6acc71c09d New CMP0016 for deciding whether an unknown target in TLL() is an error.
When set to OLD, target_link_libraries() silently accepts if it is called
with only one argument and this one argument is not a target.
When set to NEW, this is an error. By default it is a warning now.

Alex
2010-08-28 16:06:45 +02:00
Alex Neundorf da033b10d2 Remove trailing whitespace
Alex
2010-08-28 16:01:49 +02:00
Brad King e49b6eca4f Teach CMake Policies about tweak version component
Add the [.tweak] version component throughout the policy implementation.
Document all components for the cmake_policy(VERSION) command.  Record
the tweak level in which each policy was introduced (0 for all current
policies).  In generated documentation we report the tweak level only if
it is not zero.  This preserves existing documentation.
2010-04-23 09:50:31 -04:00
Brad King 02db43239b Teach link_directories to recognize relative paths
We create CMake Policy CMP0015 to make link_directories() treat relative
paths with respect to the source tree while retaining compatibility.
This makes it consistent with include_directories() and other commands.

Changes based on patch from Alex.  See issue #9697.
2009-11-24 11:16:38 -05:00
Brad King cb185d93d2 Fix if() command and CMP0012 OLD/NEW behavior
The commit "modified the if command to address bug 9123 some" changed
the if() command behavior with respect to named boolean constants.  It
introduced policy CMP0012 to provide compatibility.  However, it also
changed behavior with respect to numbers (like '2') but did not cover
the change with the policy.  Also, the behavior it created for numbers
is confusing ('2' is false).

This commit teaches if() to recognize numbers again, and treats them
like the C language does in terms of boolean conversion.  We also fix
the CMP0012 check to trigger in all cases where the result of boolean
coersion differs from that produced by CMake 2.6.4.
2009-10-27 09:07:39 -04:00
Brad King 9a77f65da7 Remove CMake Policy CMP0015 until it is revised
We revert commit "Create CMake Policy CMP0015 to fix set(CACHE)" because
the NEW behavior of the policy breaks a valid use case:

  # CMakeLists.txt
  option(BUILD_SHARED_LIBS "..." ON)
  add_library(mylib ...)
  set(BUILD_SHARED_LIBS OFF) # we want only mylib to be shared
  add_subdirectory(ThirdParty)

  # ThirdParty/CMakeLists.txt
  option(BUILD_SHARED_LIBS "..." ON)
  # uh, oh, with NEW behavior this dir uses shared libs!!!

We'll re-introduce the policy later with a different change in behavior
to resolve the motivating case, which was more subtle but less common.

See issue #9008.
2009-10-08 14:56:15 -04:00