[CMake] MSVC7.1 static link question

Philip Lowman philip at yhbt.com
Wed Feb 11 01:08:01 EST 2009


On Tue, Feb 10, 2009 at 1:01 PM, Brad King <brad.king at kitware.com> wrote:

> Bill's example will not work as written.  The target_link_libraries command
> does not work for imported targets.  See IMPORTED target and general
> packaging documentation here:
>
>  http://www.cmake.org/Wiki/CMake_2.6_Notes#Exporting_and_Importing_Targets
>  http://www.cmake.org/Wiki/CMake_2.6_Notes#Packages
>
> CMake 2.6 makes it easy to export targets from one project (either its
> build tree or install tree) for use by another project.
>

Is this the easiest way to register dependencies of IMPORTED static
libraries against each other?  I'm just curious if there are plans to make
target_link_libraries() work for this or is there a technical problem
allowing it?

project(Foo)
cmake_minimum_required(VERSION 2.6)

add_library(baz STATIC IMPORTED)
set_target_properties(baz PROPERTIES
    IMPORTED_LOCATION         ${CMAKE_CURRENT_SOURCE_DIR}/libbaz.a
    IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/libbaz.a
    IMPORTED_LOCATION_DEBUG   ${CMAKE_CURRENT_SOURCE_DIR}/libbazd.a)

add_library(bar STATIC IMPORTED)
set_target_properties(bar PROPERTIES
    IMPORTED_LOCATION         ${CMAKE_CURRENT_SOURCE_DIR}/libbar.a
    IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/libbar.a
    IMPORTED_LOCATION_DEBUG   ${CMAKE_CURRENT_SOURCE_DIR}/libbard.a)

#target_link_libraries(bar baz) # no worky
get_target_property(baz_loc     baz IMPORTED_LOCATION)
get_target_property(baz_loc_rel baz IMPORTED_LOCATION_RELEASE)
get_target_property(baz_loc_deb baz IMPORTED_LOCATION_DEBUG)
set_target_properties(bar PROPERTIES
    IMPORTED_LINK_INTERFACE_LIBRARIES         ${baz_loc}
    IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE ${baz_loc_rel}
    IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG   ${baz_loc_deb})

add_executable(foo foo.cc)
target_link_libraries(foo bar) # dependency on baz is implied


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090211/bc7f9ba0/attachment.htm>


More information about the CMake mailing list