CMake best practice for library install

和自甴很熟 提交于 2019-12-12 12:31:10

问题


I am trying an install script for a shared library with cmake. While I found out that I want to use install, I am not sure what's the best practice to set the destinations.

This comment* and various bugreports refer to LIB_INSTALL_DIR.

However I find hardly any documentation of the LIB_INSTALL_DIR

My best guess for a library install would be:

add_library(mylib SHARED ${sources})
install(TARGET mylib LIBRARY DESTINATION ${LIB_INSTALL_DIR})
install(FILES ${libheaders} DESTINATION ${??})

My questions regarding this are:

  1. How do I set LIB_INSTALL_DIR in a way that the user can overwrite it if requires (set LIB_INSTALL_DIR lib) does not allow this, does it?)
  2. What is the correct variable for the header directory? (Should I try to default it (set it to that if it is undefined) to CMAKE_SYSTEM_INCLUDE_PATH, and if so how do I do that?)
  3. install(TARGET has a INCLUDES DESTINATION, is there a better way than using manual install(FILES ${libheaders} DESTINATION ${??}) for a bunch of headers?

*first comment, by Fraser, could not find a way to link directly to the comment, only to the answer.

来源:https://stackoverflow.com/questions/36723588/cmake-best-practice-for-library-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!