I have an application which depends on a library, which uses
add_subdirectory() to include in our CMakeLists. This subdirectory is 3rd party code, and placed there as a git submodule, so I can’t easily modify CMakeLists.txt of the library itself, only the top level.
I am attempting to fix up cmake install settings for the application, and get CPack to work with it. The problem I have is that the installing the library (DLL files) also installs “includes”/header files which I don’t want to package with my application.
Is there any way to selectively choose what gets installed, from outside the library subdirectory?
Or failing that, can I specify some post-install, pre-packaging command through cmake to delete the unwanted includes?
What I tend to do in such situations is to use component install in my project and install just the binary I’m interested in as a part of my own component. Works like a charm.
I don’t understand how that would work. Could you give a small example? The library itself does not specify components by the way.
It’s quite simple. For example (simplified):
install(TARGET some_3rd_party_library_target_name COMPONENT my_dependencies)
target_link_libraries(my_exe PRIVATE some_3rd_party_library_target_name)
install(TARGET my_exe COMPONENT my_component)
There may be typos as I did it from the top of my head but hopefully you should get the general idea.