CMake: how create a single shared library from all static libraries of subprojects?

后端 未结 5 590
南旧
南旧 2020-11-30 19:36

I have the following layout:

top_project
    + subproject1
    + subproject2

Each of subproject1 and subproject2

5条回答
  •  既然无缘
    2020-11-30 19:57

    I am not sure if this is what suits your need, but cmake also offers INTERFACE libraries, which serve (among others) precisely this need.

    add_library(bundle INTERFACE)
    target_link_libraries(bundle lib1 lib2)
    

    will bundle lib1 and lib2 into a single library, and inherit the PUBLIC and INTERFACE section of lib1 and lib2.

    More info here.

提交回复
热议问题