Commit Graph

65 Commits

Author SHA1 Message Date
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Brad King dd089e08b5 install: Allow absolute EXPORT destination with relative targets (#15258)
When install(EXPORT) is given an absolute destination we cannot compute
the install prefix relative to the installed export file location.
Previously we disallowed installation of targets in such exports with a
relative destination, but did not enforce this for target property
values besides the location of the main target file.  This could lead to
broken installations when the EXPORT is installed to an absolute path
but usage requirements are specified relative to the install prefix.

Since an EXPORT installed to an absolute destination cannot be relocated
we can just hard-code the value of CMAKE_INSTALL_PREFIX as the base for
relative paths.  This will allow absolute install(EXPORT) destinations
to work with relative destinations for targets and usage requirements.

Extend the ExportImport test with a case covering this behavior.
2014-12-15 11:45:49 -05:00
Stephen Kelly e134805666 Export: Disallow export of targets with INTERFACE_SOURCES
This can be allowed in the next release, but it needs to have some
features present and tested such as

* Ensuring that relative paths do not appear in the generated property.
* Ensuring that paths to the source or build directories do not appear.
* Generating a check in the file for CMake 3.1 or later so that the
    resulting property will be consumed.
* Ensuring that any referenced targets are part of an export set and
    generating a check for them.
* INSTALL_INTERFACE and BUILD_INTERFACE content.

All of these checks are already done for INTERFACE_INCLUDE_DIRECTORIES,
but it is too late to add them for INTERFACE_SOURCES for CMake 3.1.
As the checks introduce some new error conditions, it is better to
disallow exporting fully for this case and introduce proper error
conditions later instead of policies.
2014-11-29 12:24:59 +01:00
Stephen Kelly 9eaf375598 Export: Populate INTERFACE_COMPILE_FEATURES property. 2014-04-08 11:05:07 +02:00
Stephen Kelly af8a1643c1 Remove c_str calls when using stream APIs.
Use an ad-hoc clang tool for matching the calls which should be
ported.
2014-03-11 15:03:50 +01:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel 84fdc9921c stringapi: Pass configuration names as strings 2014-03-08 13:05:36 -05:00
Brad King 4bb80396e0 CMake 3.0.0-rc1 version update 2014-02-19 09:30:12 -05:00
Stephen Kelly 6ca6613ab8 Export: Use the CMAKE_DEVEL_VERSION macro for build-export files.
Move the macro definition to the cmExportBuildFileGenerator.h header
to share it.
2014-02-11 16:31:53 +01:00
Brad King 9bcc1b21f0 Export: Fix internal CMake version test logic
Fix the internal DEVEL_CMAKE_VERSION macro to use CMake_VERSION_ENCODE
to compare version component-wise.  Otherwise an old invocation of the
macro may be tricked into using the current version when the requested
major version is smaller than the current version but the requested
minor version is larger.  It should use the requested (old) version in
that case.
2014-02-10 15:32:33 -05:00
Stephen Kelly eaf703f160 Export: Use a macro to ensure minimum development version requirement
Use the version number of the specified release, or of the current
development version if the release is not yet made.
2014-02-09 22:30:30 +01:00
Stephen Kelly af3d3b88be export: Only generate and install configuration files if needed.
The modern way to create configuration dependent content is using
generator expressions in the main export file.  The only non-deprecated
property still generated in the configuration-specific files are
IMPORTED_LOCATION_<CONFIG>

INTERFACE_LIBRARY targets have no location, and no need for those
files.
2014-01-04 11:28:56 +01:00
Stephen Kelly a0cacb5521 install: Rename variable referencing cmake version.
The next version is 3.0.0, not 2.8.13.

The version generated in the export file should be updated in
the release branch in both cmExportInstallFileGenerator and
cmExportBuildFileGenerator.
2014-01-04 11:28:56 +01:00
Stephen Kelly b51b6e97a2 Export: Skip INTERFACE libraries when generating -config files.
The properties object has just been created, so is always empty,
which means the if block is never entered. The following lines do
not have any effect because an INTERFACE library has no LOCATION.
At the end, no code is generated for INTERFACE libraries in
config-specific exported files, so skip them early.
2013-12-20 00:56:17 +01:00
Stephen Kelly 98093c45db QtAutoUic: Add INTERFACE_AUTOUIC_OPTIONS target property.
Transitively consume the property from linked dependents.

Implement configuration-specific support by following the pattern
set out for compile definitions and includes in cmQtAutoGenerators.

Implement support for origin-tracking with CMAKE_DEBUG_TARGET_PROPERTIES.

This is motivated by the needs of KDE, which provides a separate
translation system based on gettext instead of the Qt linguist
translation system. The Qt uic tool provides command line options
for configuring the method used to translate text, and to add an
include directive to the generated file to provide the method.

 http://thread.gmane.org/gmane.comp.kde.devel.frameworks/7930/focus=7992

Implement the interface to provide the uic options as a usage-requirement
on the KI18n target, as designed for KDE.
2013-11-27 19:06:12 +01:00
Stephen Kelly 4fe963f656 Use new cmHasLiteralPrefix function 2013-11-21 20:53:15 +01:00
Stephen Kelly e383555838 cmExportInstallFileGenerator: Fix comment to match reality.
It was copied from cmExportBuildFileGenerator.
2013-10-10 12:02:32 +02:00
Stephen Kelly ce0c303d62 install: Teach EXPORT option to handle INTERFACE_LIBRARY targets 2013-10-07 20:07:27 -04:00
Brad King 330db97e64 CMake 2.8.12-rc1 2013-08-15 10:53:16 -04:00
Stephen Kelly 650e61f833 Add a convenient way to add the includes install dir to the INTERFACE.
Export the INCLUDES DESTINATION without appending to the
INTERFACE_INCLUDE_DIRECTORIES of the target itself. That way, a target
can be exported multiple times with different INCLUDES DESTINATION
without unintended cross-pollution of export sets.
2013-07-24 17:32:58 +02:00
Brad King 41a2fb5ba0 Merge topic 'tid-system-argument'
9cf3547 Add the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property.
1925cff Add a SYSTEM parameter to target_include_directories (#14180)
286f227 Extend the cmTargetPropCommandBase interface property handling.
83498d4 Store system include directories in the cmTarget.
f1fcbe3 Add Target API to determine if an include is a system include.
2679a34 Remove unused variable.
2013-07-16 13:59:07 -04:00
Stephen Kelly 9cf3547e1c Add the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property.
Unlike other target properties, this does not have a corresponding
non-INTERFACE variant.

This allows propagation of system attribute on include directories
from link dependents.
2013-07-16 13:44:57 -04:00
Stephen Kelly 574fec97fd Export: Generate INTERFACE_LINK_LIBRARIES property on targets.
This property is generated only for targets which have recorded
policy CMP0022 as NEW, and a compatibility mode is added to
additionally export the old interfaces in that case too.

If the old interfaces are not exported, the generated export files
require CMake 2.8.12. Because the unit tests use a version which
is not yet called 2.8.12, temporarily require a lower version.
2013-07-08 22:39:57 +02:00
Stephen Kelly 77ff352aa7 Generate INTERFACE_COMPILE_OPTIONS on export.
This was missing from commit 80ca9c4b (Add COMPILE_OPTIONS target
property., 2013-05-16).
2013-06-10 16:50:20 +02:00
Brad King 05e47f2122 Merge topic 'cfbundle-location'
483e208 OS X:  Fix getting of CFBundle LOCATION property.
2013-06-04 09:02:46 -04:00
Brad King 3caf565d07 Merge topic 'rpath-on-mac'
dc1d025 OS X: Add test for rpaths on Mac.
8576b3f OS X: Add support for @rpath in export files.
00d71bd Xcode: Add rpath support in Xcode generator.
94e7fef OS X: Add RPATH support for Mac.
2013-06-03 09:56:44 -04:00
Brad King b0759da303 Merge topic 'framework-refactor'
373faae Refactor how bundles and frameworks are supported.
2013-06-03 09:56:32 -04:00
Clinton Stimpson 8576b3f978 OS X: Add support for @rpath in export files.
Also expand the IMPORTED_SONAME property for targets
to match the install_name.
2013-06-03 09:42:05 -04:00
Clinton Stimpson 483e208482 OS X: Fix getting of CFBundle LOCATION property.
This fixes bug #13797.
The kinds of changes applied in 373faae5 for frameworks are now
applied to CFBundle.  The prefix and suffix for CFBundles are
now handled in cmTarget::GetFullNameInternal.
2013-06-03 06:29:33 -06:00
Clinton Stimpson 373faae5e1 Refactor how bundles and frameworks are supported.
Make handling of directory separators consistent between
non-bundle and bundle code.

Remove xcode specific flag from cmTarget when getting install_name.

Add (more) consistent convenience functions in cmTarget to get
directories inside of bundles and frameworks to add files to.

This refactor also fixes bug #12263 where frameworks
had the wrong install name when SKIP_BUILD_RPATH.

Also make install_name for frameworks consistent between Makefile
and Xcode generator.
2013-05-23 10:42:49 -04:00
Stephen Kelly b5d6f5dd5b Add EXPORT_NAME property.
This allows for example, the buildsystem to use names like 'boost_any'
instead of the overly generic 'any', and still be able to generate
IMPORTED targets called 'boost::any'.
2013-05-18 10:00:48 +02:00
Brad King 6c613b433c Handle usr-move without forcing absolute paths (#14041)
In commit 0c727b90 (install(EXPORT): Force absolute paths for usr-move,
2013-03-08) and commit d4774140 (configure_package_config_file: force
absolute paths for usr-move, 2013-01-24) we supported Linux
distributions implementing the "/usr move" by assuming that installation
to (/usr)?/lib(64)? represents a non-relocatable system package.

When cross-compiling one may prepare a package for installation into a
system location on a target machine but install the package files on the
*host* machine inside another path for use with CMAKE_FIND_ROOT_PATH.
In this case the package development files must still be relocatable.

Handle "/usr move" with a new approach that works with relocatable
files.  Teach configure_package_config_file and install(EXPORT) to
generate special logic in a package configuration file or targets file
for installation under (/usr)?/lib(64)?.  Teach the file to recognize
when it is loaded through a symlink that refers to the same realpath as
its original install destination.  In such a case, use the original
install prefix.  Otherwise, compute the prefix relative to the current
file location to make it relocatable.
2013-04-03 11:19:47 -04:00
Stephen Kelly af81a3c31b install(EXPORT): Ensure clean INTERFACE_INCLUDE_DIRECTORIES
Check that source and binary directories are not part of the
INTERFACE_INCLUDE_DIRECTORIES for installed IMPORTED targets.

This is limited to directories which do not contain generator
expressions to evaluate. Such paths can only be checked at time
of use of the imported target, which will be done in a follow up
patch.
2013-03-26 10:45:07 -04:00
Brad King 0c727b906a install(EXPORT): Force absolute paths for usr-move
If the absolute install(EXPORT) destination for the CMAKE_INSTALL_PREFIX
used during configuration is under (/usr)?/lib(64)? then assume the
current build is for a system package installation instead of a
relocatable distribution.  Generate an absolute path for _IMPORT_PREFIX
in the target exports file instead of generating code to compute the
value relative to the file location.  This is necessary for
distributions implementing a move to /usr such as:

 https://wiki.archlinux.org/index.php/DeveloperWiki:usrlib
 "All files in the /lib directory have been moved to /usr/lib and now
  /lib is a symlink to usr/lib."

The relative path computation is not reliable because the targets file
could be installed through cross-prefix a symlink and loaded without it
or vice versa.

A similar change was made for package configuration file generation by
commit d4774140 (configure_package_config_file: force absolute paths for
usr-move, 2013-01-24).
2013-03-08 09:55:18 -05:00
Stephen Kelly 34d1ade048 Add the INSTALL_PREFIX genex. 2013-01-27 09:59:26 +01:00
Stephen Kelly 3a1719793f Generate the _IMPORT_PREFIX in the non-config export file. 2013-01-27 09:42:54 +01:00
Brad King 33695c616a Merge topic 'export-new-style-files'
02d4e53 Generate new-style cmake code during export.
2013-01-23 15:11:32 -05:00
Stephen Kelly 830246e841 Export the COMPATIBLE_INTERFACE_BOOL content properties 2013-01-21 09:05:03 +01:00
Stephen Kelly 02d4e53f48 Generate new-style cmake code during export.
Use empty end*() commands and lowercase commands.
2013-01-20 18:05:23 +01:00
Stephen Kelly 522bdac149 Export the INTERFACE_PIC property. 2013-01-15 14:36:22 -05:00
Stephen Kelly 6c828f9126 Move the exported check for file existence.
Check only once, in the Config.cmake file, instead of once in each
Config-<cfg>.cmake file.
2013-01-15 14:36:21 -05:00
Stephen Kelly cfd4f0a4f4 Move the exported check for dependencies of targets
Check only once, in the Config.cmake file, instead of once in each
Config-<cfg>.cmake file.
2013-01-15 14:36:21 -05:00
Stephen Kelly 94aeaf72c7 Split LINK_INTERFACE_LIBRARIES export handling into dedicated method. 2013-01-10 18:06:57 +01:00
Stephen Kelly 894f52f32d Handle INTERFACE properties transitively for includes and defines.
Contextually, the behavior is as if the properties content from another
target is included in the string and then the result is evaluated.
2013-01-05 01:18:37 +01:00
Stephen Kelly f5b1980fb2 Populate the ExportedTargets member early in GenerateMainFile
The member variable is checked to determine whether to call
HandleMissingTarget(). As that could be called during the loop in
the comming commits, ensure that it contains all targets being
exported.
2013-01-05 01:18:37 +01:00
Stephen Kelly bf2ddceb4e Generate an early-return guard in target Export files.
Previously it was necessary for writers of Config files
which incude exported target files to write the guard themselves, but
this was not immediately obvious or documented. Options for them
would be to use a variable, or an INHERITED directory property in an
effort to avoid accidental name clashes in all contexts in
which find_package can be used.

Getting this right requires boiler plate code, so generate a simpler
check automatically instead.
2012-11-30 09:51:17 +01:00
Alex Neundorf 0cfd055acd exports: move the handling of missing targets into subclasses
Before, cmExportFileGenerator::ComplainAboutMissingTarget() was a virtual
function which had to be implemented in the subclasses. It is not
anymore. Instead, there is now a virtual function
HandleMissingTargets(), which is implemented in the two subclasses.
This makes e.g. dealing correctly with APPEND mode easier.

Alex
2012-09-30 10:26:10 -04:00
Alex Neundorf 190f2c8253 exports: fix build with MSVC6
it seems it doesn't like deleting const pointers

Alex
2012-09-28 17:00:52 -04:00
Alex Neundorf 8b5f448ba6 exports: first try at error handling if a target is missing
Now, if an imported target depends on a library which must come
from some other export set, cmake generates a check which errors
out if that target does not exist. I guess instead of completely
erroring out it would be better to only make the find_package() fail.

Alex
2012-09-28 09:21:42 -04:00
Alex Neundorf 87f4c01910 exports: accept a missing target if it is exported exactly once
If a target is exported, and a library it depends on is not part
of the same export set, before this patch cmake errored out.
With this patch, it now checks whether the missing target
is exported somewhere else exactly once, and accepts in this
case (because then it can determine the namespace for the
missing target and use this).

Alex
2012-09-28 09:21:42 -04:00