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:
- 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?) - 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?) install(TARGET
has aINCLUDES DESTINATION
, is there a better way than using manualinstall(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.