# Создание статической и динамической библиотеки из одинаковых объектных файлов function(add_common_library) set(options) set(oneValueArgs TARGET) set(multiValueArgs SOURCES) cmake_parse_arguments(_LOCAL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(LIBNAME ${_LOCAL_TARGET}) set(SOURCES ${_LOCAL_SOURCES}) add_library(${LIBNAME} OBJECT ${SOURCES}) target_include_directories( ${LIBNAME} PUBLIC $ $ $) set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) if(BUILD_SHARED_LIBS) add_library(${LIBNAME}_shared SHARED $) set_target_properties(${LIBNAME}_shared PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} OUTPUT_NAME ${LIBNAME} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) endif() add_library(${LIBNAME}_static STATIC $) set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc) endfunction()