I’m learning about how to install targets, and I’ve stumbled across the following situation. I understand that if I have a library Foo
, you can specify a variety of paths for the install.
install(Targets Foo
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
However, in my situation, I don’t care about archive installs. I’m installing to run applications. So if those applications need Foo as a shared library, then I want to install, but if the application built with Foo as an archive, then I don’t need to install it. What are my options? Do I just have to check if Foo is a SHARED_LIBRARY, and only add the install clause then?
get_target_property(target_type <target> TYPE)
if (target_type STREQUAL "SHARED_LIBRARY")
install(Targets Foo
LIBRARY DESTINATION lib)
endif ()