Commit Graph

11 Commits

Author SHA1 Message Date
Brad King d76b20bf3a BUG: Avoid bogus dependency on executable targets
When an executable target within the project is named in
target_link_libraries for another target, but the executable does not
have the ENABLE_EXPORTS property set, then the executable cannot really
be linked.  This is probably a case where the user intends to link to a
third-party library that happens to have the same name as an executable
target in the project (or else will get an error at build time).  We
need to avoid making the other target depend on the executable target
incorrectly, since the executable may actually want to link to that
target and this is not a circular depenency.
2008-08-06 17:48:53 -04:00
Brad King 08221c2a49 BUG: Preserve all non-targets on user link lines
In CMake 2.4 the generated link line for a target always preserved the
originally specified libraries in their original order.  Dependencies
were satisfied by inserting extra libraries into the line, though it had
some bugs.  In CMake 2.6.0 we preserved only the items on the link line
that are not known to be shared libraries.  This reduced excess
libraries on the link line.  However, since we link to system libraries
(such as /usr/lib/libm.so) by asking the linker to search (-lm), some
linkers secretly replace the library with a static library in another
implicit search directory (developers can override this by using an
imported target to force linking by full path).  When this happens the
order still matters.

To avoid this and other potential subtle issues this commit restores
preservation of all non-target items and static library targets.  This
will create cases of unnecessary, duplicate shared libraries on the link
line if the user specifies them, but at least it will work.  In the
future we can attempt a more advanced analysis to safely remove
duplicate shared libraries from the link line.
2008-07-30 10:23:41 -04:00
Brad King 3a5bdaa213 ENH: When preserving potentially static portions of original user link lines recognize shared library names by their extension and skip them. 2008-04-30 18:04:48 -04:00
Brad King 85c983885b BUG: Fix preservation of static libraries on original link lines. 2008-04-23 00:40:19 -04:00
Brad King 3652a8e913 BUG: Fix bug 6605 more completely
- CMake 2.4 added link directories for targets linked
    in the optimized configuration even when building debug
  - Old behavior for policy CMP0003 must account for this
2008-03-31 12:47:31 -04:00
Brad King bf4cef9d5c ENH: Add policy CMP_0004 to require library names to have no leading or trailing whitespace. Replace previous check of CMAKE_BACKWARDS_COMPATIBILITY against version 2.4 with the policy. 2008-03-13 16:35:39 -04:00
Brad King 98621ecfaa BUG: Update cmComputeLinkDepends to support leading/trailing whitespace stripping off link items for compatibility. 2008-02-13 15:29:55 -05:00
Brad King 4987e17f46 ENH: Improve link line generation for static library cycles.
- Move Tarjan algorithm from cmComputeTargetDepends
    into its own class cmComputeComponentGraph
  - Use cmComputeComponentGraph to identify the component DAG
    of link dependencies in cmComputeLinkDepends
  - Emit non-trivial component members more than once but always
    in a contiguous group on the link line
2008-02-07 16:14:05 -05:00
Brad King 2cff26fa52 ENH: Support linking to shared libs with dependent libs
- Split IMPORTED_LINK_LIBRARIES into two parts:
      IMPORTED_LINK_INTERFACE_LIBRARIES
      IMPORTED_LINK_DEPENDENT_LIBRARIES
  - Add CMAKE_DEPENDENT_SHARED_LIBRARY_MODE to select behavior
  - Set mode to LINK for Darwin (fixes universal binary problem)
  - Update ExportImport test to account for changes
2008-01-31 15:45:31 -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
Brad King 99b97dece8 ENH: Created cmComputeLinkDepends to compute link dependencies.
- This will be useful for imported library dependencies
  - Replaces old cmTarget analyze-lib-depends stuff for linking
  - Formalizes graph construction and dump
  - Explicitly represents dependency inferral sets
  - Use BFS of initial dependencies to preserve order
2008-01-27 13:42:49 -05:00