[CMake] How to define custom import library name (MSVC)?

Michael Hertling mhertling at online.de
Mon Oct 17 07:58:07 EDT 2011


On 10/16/2011 06:27 PM, zex spectrum wrote:
> Hello,
> 
> I generate a shared library named, for example, mylib80.dll (it has
> postfix "80", because I want to embed version info into library name.
> I use set_target_properties with <Config>_POSTFIX property to achieve
> this. By default, CMake names corresponding import library as
> mylib80.lib. But I want my shared lib to have an import lib named
> mylib.lib (without version embedded into its name). Is it possible at
> all? I tried IMPORT_SUFFIX, but it seems to not work as I expect.

AFAIK, a shared library target's import library is named like

... + ARCHIVE_OUTPUT_NAME_<CONFIG> + <CONFIG>_POSTFIX + IMPORT_SUFFIX

so you cannot use the IMPORT_SUFFIX to overwrite the <CONFIG>_POSTFIX.

> I use MSVC, I do not need to have this for GCC and other compilers.
> 
> Any help would be appreciated.

You might use an additional INSTALL(CODE ...) step, see the attached
CMakeLists.txt file. Note that the LOCATION property might have side
effects, cf. [1], so it's probably best to place it at the very end.

'hope that helps.

Regards,

Michael

[1] http://public.kitware.com/Bug/view.php?id=11671
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111017/a72622d6/attachment.txt>


More information about the CMake mailing list