I am trying to export a library from a CMake project. Internally, I've broken this library up into multiple sub-targets. I would now like to export just the full public library, without needing my private library binaries. The following doesn't work.
cmake_minimum_required(VERSION 3.2)
project(export-mwe)
add_library(priv priv.cpp)
add_library(exp-lib exp-lib.cpp)
target_link_libraries(exp-lib PRIVATE priv)
install(TARGETS exp-lib EXPORT export-mwe DESTINATION lib)
install(EXPORT export-mwe DESTINATION .)
When I try generating this project I get an error.
CMake Error: install(EXPORT "export-mwe" ...) includes target "exp-lib" which requires target "priv" that is not in the export set.
How can I export only exp-lib
in this example, without having to export priv
with it?