View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014838CMakeCMakepublic2014-03-25 16:212016-06-10 14:31
ReporterNico Schlömer 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0014838: INSTALL(EXPORT ...) sets IMPORTED_LINK_INTERFACE_LIBRARIES_* differently from linker
DescriptionWhen linking a library against, say, liblapack.so,

TARGET_LINK_LIBRARIES(mytarget lapack)

the link line will contain something along the lines of `/usr/lib/liblapack.so` (mostly a symlink), which the linker will correctly resolve to wherever the actual LAPACK binary sits; e.g.,

$ ldd /opt/trilinos/lib/libepetra.so
[...]
    liblapack.so.3gf => /usr/lib/liblapack.so.3gf (0x00007fae46c64000)
[...]

When using CMake's INSTALL(EXPORT ...) functionality, the exported files will contain `IMPORTED_LINK_INTERFACE_LIBRARIES_<build type>` with LAPACK as appearing on the link line, e.g.,

set_property(TARGET epetra APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
set_target_properties(epetra PROPERTIES
  IMPORTED_LINK_INTERFACE_LIBRARIES_RELWITHDEBINFO "/usr/lib/liblapack.so"
  IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib/libepetra.so.11.7"
  IMPORTED_SONAME_RELWITHDEBINFO "libepetra.so.11"
  )

This poses problems whenever you use this exported information since it requires the symlink /usr/lib/liblapack.so to exist when really all you need is /usr/lib/liblapack.so.3gf.

A typical case for where this causes conflicts is Debian. Here, the former (/usr/lib/liblapack.so) is part of liblapack-dev, the latter (/usr/lib/liblapack.so.3gf) of the separate package liblapack.

I suppose the exported information should reflect as accurately as possible what is actually required by the library and thus follow the symlinks just like the linker does.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0035514)
Ben Boeckel (developer)
2014-03-25 21:51

The export file should also be part of the -dev package also, so there should be no problem here (e.g., how are you using liblapack without its headers?)
(0035517)
Nico Schlömer (reporter)
2014-03-26 06:18

If libA uses LAPACK and only includes LAPACK's headers and functions in its source files, libA doesn't export an interface to LAPACK and building against libA (with its headers in libA-dev) doesn't require knowledge of the LAPACK interface, i.e., liblapack-dev.

I suppose a fundamental question here is: How does CMake determine if libA provides an interface to LAPACK? In other words: Why does CMake tag the LAPACK-dependecy as IMPORTED_LINK_INTERFACE_LIBRARIES_RELWITHDEBINFO instead of IMPORTED_LINK_DEPENDENT_LIBRARIES_RELWITHDEBINFO?
(0035518)
Brad King (manager)
2014-03-26 08:38

Read the documentation of target_link_libraries to see how it decides whether a dependency is in the interface or not. The preferred method has changed recently so see documentation for each version:

 v3.0: http://www.cmake.org/cmake/help/v3.0/command/target_link_libraries.html [^]
 v2.8.12: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:target_link_libraries [^]
 v2.8.11: http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:target_link_libraries [^]

Quick answer:

 target_link_libraries(mytarget PRIVATE lapack)

or to work with CMake versions older than 2.8.12:

 target_link_libraries(mytarget LINK_PRIVATE lapack)
(0042518)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2014-03-25 16:21 Nico Schlömer New Issue
2014-03-25 21:51 Ben Boeckel Note Added: 0035514
2014-03-26 06:18 Nico Schlömer Note Added: 0035517
2014-03-26 08:38 Brad King Note Added: 0035518
2016-06-10 14:29 Kitware Robot Note Added: 0042518
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team