# Create a shared and static library function(add_common_library LIBNAME SOURCES) add_library(${LIBNAME} OBJECT ${SOURCES}) target_include_directories(${LIBNAME} PUBLIC $ $ $) get_property(VER GLOBAL PROPERTY VERSION_STR) get_property(SOVER GLOBAL PROPERTY VERSION_MAJOR) set_property(TARGET ${LIBNAME} PROPERTY VERSION "${VER}") set_property(TARGET ${LIBNAME} PROPERTY SOVERSION "${SOVER}") set_property(TARGET ${LIBNAME} PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(${LIBNAME}_shared SHARED $) set_target_properties(${LIBNAME}_shared PROPERTIES OUTPUT_NAME ${LIBNAME}) add_library(${LIBNAME}_static STATIC $) set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME}) set(_libdir "${CMAKE_BINARY_DIR}/lib") if(DEFINED ENV{DEB_HOST_MULTIARCH}) string(APPEND _libdir "/$ENV{DEB_HOST_MULTIARCH}") endif() set_target_properties(${LIBNAME}_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_libdir}) set_target_properties(${LIBNAME}_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${_libdir}) endfunction()