[cmake-developers] Policy for INTERFACE_LINK_LIBRARIES
Brad King
brad.king at kitware.com
Fri Dec 7 10:19:39 EST 2012
On 12/06/2012 05:00 PM, Stephen Kelly wrote:
> Currently it doesn't seem to work. Using current master with this:
>
> add_library(picon SHARED libone.cpp)
> add_library(picoff SHARED libtwo.cpp)
> target_link_libraries(picoff picon)
>
> export(TARGETS
> picon
> NAMESPACE foo_
> FILE foo_iface.cmake
> )
>
> export(TARGETS
> picoff
> NAMESPACE bar_
> FILE bar_iface.cmake
> )
>
> Results in an error:
>
> CMake Error at CMakeLists.txt:99 (export):
> export called with target "picoff" which requires target "picon" that is
> not in the export list.
IIRC the topic that added dependent export support was only
finished for the install(EXPORT) command and not for export().
It added a test for the install case mixing namespaces:
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=955b9662
It appears to work. The install tree contains one export with:
# Create imported target Req::testLibRequired
ADD_LIBRARY(Req::testLibRequired STATIC IMPORTED)
...
# Import target "Req::testLibRequired" for configuration "Debug"
SET_PROPERTY(TARGET Req::testLibRequired APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
SET_TARGET_PROPERTIES(Req::testLibRequired PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/libtestLibRequired.a"
)
and a dependent export with:
# Create imported target testLibDepends
ADD_LIBRARY(testLibDepends STATIC IMPORTED)
...
# Make sure the targets which have been exported in some other
# export set exist.
IF(NOT TARGET "Req::testLibRequired" )
IF(CMAKE_FIND_PACKAGE_NAME)
SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Required imported target \"Req::testLibRequired\" not found ! ")
ELSE()
MESSAGE(FATAL_ERROR "Required imported target \"Req::testLibRequired\" not found ! ")
ENDIF()
ENDIF()
...
# Import target "testLibDepends" for configuration "Debug"
SET_PROPERTY(TARGET testLibDepends APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
SET_TARGET_PROPERTIES(testLibDepends PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "Req::testLibRequired"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/libtestLibDepends.a"
)
This will need to work in the new interface.
-Brad
More information about the cmake-developers
mailing list