Commit Graph

35 Commits

Author SHA1 Message Date
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
Yury G. Kudryashov 81cdab5bea exports: Hold an ExportSet pointer in cm*Export*Generator
Get name from this->ExportSet.
2012-09-28 09:21:39 -04:00
Yury G. Kudryashov d13ec1ac31 exports: Create class cmExportSet
Replace direct use of 'std::vector<cmTargetExport const*>' with a
dedicated class.
2012-09-28 09:21:39 -04:00
Yury G. Kudryashov 81c66c8b88 exports: Move cmTargetExport to a dedicated header file 2012-09-28 09:21:38 -04:00
Alex Neundorf a2be068c75 install(EXPORT): Enforce existence of imported target files
Typical <package>Config.cmake files for find_package() rely only on the
files generated by install(EXPORT).  They might be wrong, for whatever
reasons, like people manually deleted files, projects were packaged
wrong by distributions, whatever.  To protect against this, add checks
that the file locations we are importing actually exist on disk.

Alex
2011-11-22 15:55:00 -05:00
Richard Bateman 5457b8254c Add support for CFBundle targets on the Mac (#11295)
This commit enables building, for example, plugin bundles
to be loaded by web browsers.
2011-01-11 12:54:44 -05:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King 254782ed76 ENH: Refactor computation of import file glob
New method cmExportInstallFileGenerator::GetConfigImportFileGlob
computes the globbing expression that an installed export file uses to
load its per-configuration support files.
2009-01-07 14:16:28 -05:00
Brad King 9e64d5b272 ENH: Improve exporting/importing of targets
- Use real name instead of link for location of versioned targets
  - Error when a target is exported multiple times
2008-02-06 14:20:36 -05:00
Brad King 0dac20cd20 BUG: Fixed typo resulting in confusing error message from cmExportInstallFileGenerator. 2008-02-01 14:35:14 -05:00
Brad King 82fcaebe28 ENH: Pass dependent library search path to linker on some platforms.
- Move runtime path ordering out of cmComputeLinkInformation
    into its own class cmOrderRuntimeDirectories.
  - Create an instance of cmOrderRuntimeDirectories for runtime
    path ordering and another instance for dependent library
    path ordering.
  - Replace CMAKE_DEPENDENT_SHARED_LIBRARY_MODE with explicit
    CMAKE_LINK_DEPENDENT_LIBRARY_FILES boolean.
  - Create CMAKE_LINK_DEPENDENT_LIBRARY_DIRS boolean.
  - Create variables to specify -rpath-link flags:
      CMAKE_SHARED_LIBRARY_RPATH_LINK_<LANG>_FLAG
      CMAKE_EXECUTABLE_RPATH_LINK_<LANG>_FLAG
  - Enable -rpath-link flag on Linux and QNX.
  - Documentation and error message updates
2008-02-01 08:56:00 -05:00
Brad King 7902bc06aa ENH: Implemented link-interface specification feature.
- Shared libs and executables with exports may now have
    explicit transitive link dependencies specified
  - Created LINK_INTERFACE_LIBRARIES and related properties
  - Exported targets get the interface libraries as their
    IMPORTED_LINK_LIBRARIES property.
  - The export() and install(EXPORT) commands now give
    an error when a linked target is not included since
    the user can change the interface libraries instead
    of adding the target.
2008-01-30 17:25:52 -05:00
Brad King e75932b61f STYLE: Updated TODO comment for PUBLIC_HEADER_LOCATION export. 2008-01-28 15:22:07 -05:00
Brad King e3b1bdb058 ENH: Support exporting/importing of AppBundle targets.
- Imported bundles have the MACOSX_BUNDLE property set
  - Added cmTarget::IsAppBundleOnApple method to simplify checks
  - Document BUNDLE keyword in INSTALL command
  - Updated IMPORTED_LOCATION property documentation for bundles
  - Updated ExportImport test to test bundles
2008-01-28 14:46:16 -05:00
Brad King 28ea034737 ENH: Support exporting/importing of Framework targets.
- Imported frameworks have the FRAMEWORK property set
  - Added cmTarget::IsFrameworkOnApple method to simplify checks
  - Also remove separate IMPORTED_ENABLE_EXPORTS property and just use ENABLE_EXPORTS since, like FRAMEWORK, it just represents the target type.
  - Document FRAMEWORK keyword in INSTALL command.
  - Updated IMPORTED_LOCATION property documentation for Frameworks
2008-01-28 13:05:58 -05:00
Brad King 5594ad4885 ENH: Updated exporting and importing of targets to support libraries and configurations.
- Created cmExportFileGenerator hierarchy to implement export file generation
  - Installed exports use per-config import files loaded by a central one.
  - Include soname of shared libraries in import information
  - Renamed PREFIX to NAMESPACE in INSTALL(EXPORT) and EXPORT() commands
  - Move addition of CMAKE_INSTALL_PREFIX to destinations to install generators
  - Import files compute the installation prefix relative to their location when loaded
  - Add mapping of importer configurations to importee configurations
  - Rename IMPORT targets to IMPORTED targets to distinguish from windows import libraries
  - Scope IMPORTED targets within directories to isolate them
  - Place all properties created by import files in the IMPORTED namespace
  - Document INSTALL(EXPORT) and EXPORT() commands.
  - Document IMPORTED signature of add_executable and add_library
  - Enable finding of imported targets in cmComputeLinkDepends
2008-01-28 08:38:36 -05:00