CMAKE - How to properly copy static library's header file into /usr/include?

前端 未结 4 1500
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 20:26

I\'m getting into CMAKE usage with C and actually I\'m creating two very small static libraries.

My goal is:

  1. The libraries are compiled and linked into
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 21:19

    A better way for newest cmake version is to use target's PUBLIC_HEADER properties.

    project(myproject)
    
    add_library(mylib some.c another.c)
    set_target_properties(mylib PROPERTIES PUBLIC_HEADER "some.h;another.h")
    INSTALL(TARGETS mylib 
            LIBRARY DESTINATION some/libpath
            PUBLIC_HEADER DESTINATION some/includepath
    )
    

    Some ref:

    PUBLIC_HEADER

    CMake install command

提交回复
热议问题