[CMake] Alias of imported target
CHEVRIER, Marc
marc.chevrier at sap.com
Wed May 6 02:51:12 EDT 2015
My need is the following:
I have two imported targets, let say, IMPORTED::TARGET and IMPORTED::STATIC::TARGET
And I have a project which can be customised, through an option, by selecting which imported target will be used (shared or static).
So I tried, at first place:
if (USE_IMPORTED_STATIC)
add_library (MY_IMPORTED_TARGET ALIAS IMPORTED::STATIC::TARGET)
else()
add_library (MY_IMPORTED_TARGET ALIAS IMPORTED::TARGET)
endif()
So, after, I do not longer take care of which imported target is selected!
For now, I rely on a variable storing selected imported target but it is, by far, less elegant and coherent with target handling.
On 05/05/15 19:01, "Stephen Kelly" <steveire at gmail.com> 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.
>
>
>--
>
>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
More information about the CMake
mailing list