include_guard(GLOBAL) if(${CMAKE_VERSION} VERSION_LESS "3.17.0") set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}) endif() include(CMakePackageConfigHelpers) function(myx_install_library NAME) if(NOT PROJECT_IS_TOP_LEVEL) return() endif() write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) configure_package_config_file( ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/InstallLibraryConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME} NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO ) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev ) install(EXPORT ${NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME} COMPONENT dev ) install( FILES ${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake ${PROJECT_BINARY_DIR}/${NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME} COMPONENT dev ) 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() endfunction()