Suppose that I've got the following libraries:
add_library(myLib_static STATIC ${SRC_FILES})
add_library(myLib SHARED ${SRC_FILES})
# installing header files
install(FILES ${H_FILES} DESTINATION ${INSTDIRHEADER})
# installing binaries
install(TARGETS myLib_static
DESTINATION ${INSTDIRBIN})
install(TARGETS myLib
DESTINATION ${INSTDIRBIN})
If I execute the following command, both shared and static libraries will be installed:
make install
How can I have separate install commands for each of them? Something like this:
make install-static
make install-shared
Update:
Header files should also be installed when needed:
install(FILES ${H_FILES} DESTINATION ${INSTDIRHEADER})
Put them each in a different component and set up custom targets for the installations.
Then invoke the custom targets.
Note that components are used by cpack to allow the user installing a package to decide which components to install. So, for a library, the headers might be part of the Development component. In this case we install the header with both the shared and static component. It might make sense to additionally install it with a Development component if cpack is to be used in that way.