On 05-May-15 20:01, Stephen Kelly wrote:
CHEVRIER, Marc wrote:

Hi,

Currently it is not possible to create an alias target for an imported
target (I.e. add_library with ALIAS keyword). But I don’t understand what
is the technical constraint or semantic reason behind this limitation. If
anybody can explain this limitation, it will be nice.
It was designed with as many restrictions as I could think of (everything
which was not part of the need to add it at all):

  http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=370bf554

The restrictions are there because they are easy to lift later when a need
arises without breaking user code. It also means that design considerations
which were not known or understood two years ago can be considered in
designing new interfaces.

Do you have a need for ALIAS IMPORTED libraries? Can you describe it?

Thanks,

Steve.


It may be helpful in situations when you build package with examples. In case when you want examples to work both as a part of a project (add_subdirectory) or stand-alone (find_package).

For instance:
    if(TARGET bar)
      # bar and boo targets in the same project
      add_library(Foo::bar ALIAS bar)
    else()
      # boo installed first, bar build as a stand-alone project
      find_package(Foo CONFIG REQUIRED) # target Foo::bar
    endif()
    target_link_libraries(boo Foo::bar)

If ALIAS will be allowed for imported targets we can write:

  if(NOT TARGET bar)
    find_package(Foo CONFIG REQUIRED)
    add_libarary(bar ALIAS Foo::bar)
  endif()
  target_link_libraries(boo bar)

We are not saving any space here and it's not critical feature, but this symmetry looks reasonable.

Ruslo
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to