Can I install shared imported library?

后端 未结 1 1632
闹比i
闹比i 2020-12-03 14:04

I have an external project and an imported shared library. The include directories and implib all work correctly, but trying to install the shared library (dll) fails with t

相关标签:
1条回答
  • 2020-12-03 14:36

    CMake doesn't allow to install IMPORTED libraries as TARGETS. Use install(FILES) instead.

    There are at least 2 reasons for such behavior:

    1. Сitation of one of CMake developer from bug report

      Imported targets were originally designed for importing from an existing installation of some external package so installing did not make sense at the time.

    2. When install normal library, CMake is able to modify it for adjust some properties like RPATH. Such modification is possible because CMake knows how the library has been built. This is a main advantage of installing library as a TARGET.

      But for IMPORTED library CMake has no information about the library's compilation process, and cannot perform any reasonable modification of it. So, CMake may only install the library file as is: no advantages against simple install(FILES).

    0 讨论(0)
提交回复
热议问题