2019-02-12 20:02:48 +00:00
|
|
|
# Создание статической и динамической библиотеки из одинаковых объектных файлов
|
2019-02-12 16:31:17 +00:00
|
|
|
function(add_common_library LIBNAME SOURCES)
|
|
|
|
add_library(${LIBNAME} OBJECT ${SOURCES})
|
|
|
|
target_include_directories(${LIBNAME} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
|
|
|
|
$<INSTALL_INTERFACE:include/${LIBNAME}>)
|
2019-02-12 20:02:48 +00:00
|
|
|
set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
|
|
|
add_library(${LIBNAME}_shared SHARED $<TARGET_OBJECTS:${LIBNAME}>)
|
2019-02-12 20:02:48 +00:00
|
|
|
get_property(_ver GLOBAL PROPERTY VERSION_STR)
|
|
|
|
get_property(_sover GLOBAL PROPERTY VERSION_MAJOR)
|
|
|
|
set_target_properties(${LIBNAME}_shared PROPERTIES
|
|
|
|
VERSION ${_ver}
|
|
|
|
SOVERSION ${_sover}
|
|
|
|
OUTPUT_NAME ${LIBNAME}
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
|
2019-02-12 16:31:17 +00:00
|
|
|
|
|
|
|
add_library(${LIBNAME}_static STATIC $<TARGET_OBJECTS:${LIBNAME}>)
|
2019-02-12 20:02:48 +00:00
|
|
|
set_target_properties(${LIBNAME}_static PROPERTIES
|
|
|
|
OUTPUT_NAME ${LIBNAME}
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
|
2019-02-13 18:34:20 +00:00
|
|
|
configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc)
|
2019-02-12 16:31:17 +00:00
|
|
|
endfunction()
|
|
|
|
|