diff --git a/lib/InstallLibrary.cmake b/lib/InstallLibrary.cmake index f2a18d4..21296ed 100644 --- a/lib/InstallLibrary.cmake +++ b/lib/InstallLibrary.cmake @@ -11,6 +11,8 @@ function(myx_install_library NAME) return() endif() + get_target_property(type ${NAME} TYPE) + write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} @@ -43,22 +45,30 @@ function(myx_install_library NAME) COMPONENT dev ) - if(TARGET ${NAME}_shared) - install( - TARGETS ${NAME}_shared - EXPORT ${NAME}Targets - LIBRARY - DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT lib - ) + if(${type} STREQUAL "OBJECT_LIBRARY") + if(TARGET ${NAME}_shared) + install( + TARGETS ${NAME}_shared + EXPORT ${NAME}Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT lib + ) + endif() + + if(TARGET ${NAME}_static) + install( + TARGETS ${NAME}_static + EXPORT ${NAME}Targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT lib + ) + endif() endif() - if(TARGET ${NAME}_static) + if(${type} STREQUAL "INTERFACE_LIBRARY") install( - TARGETS ${NAME}_static + TARGETS ${NAME} EXPORT ${NAME}Targets - ARCHIVE - DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib ) endif()