Исправление функции для создания библиотек
This commit is contained in:
parent
405cced4a5
commit
2a741e657f
@ -1,27 +1,24 @@
|
|||||||
# Create a shared and static library
|
# Создание статической и динамической библиотеки из одинаковых объектных файлов
|
||||||
function(add_common_library LIBNAME SOURCES)
|
function(add_common_library LIBNAME SOURCES)
|
||||||
add_library(${LIBNAME} OBJECT ${SOURCES})
|
add_library(${LIBNAME} OBJECT ${SOURCES})
|
||||||
target_include_directories(${LIBNAME} PUBLIC
|
target_include_directories(${LIBNAME} PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include/${LIBNAME}>)
|
$<INSTALL_INTERFACE:include/${LIBNAME}>)
|
||||||
get_property(VER GLOBAL PROPERTY VERSION_STR)
|
set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
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 $<TARGET_OBJECTS:${LIBNAME}>)
|
add_library(${LIBNAME}_shared SHARED $<TARGET_OBJECTS:${LIBNAME}>)
|
||||||
set_target_properties(${LIBNAME}_shared PROPERTIES OUTPUT_NAME ${LIBNAME})
|
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})
|
||||||
|
|
||||||
add_library(${LIBNAME}_static STATIC $<TARGET_OBJECTS:${LIBNAME}>)
|
add_library(${LIBNAME}_static STATIC $<TARGET_OBJECTS:${LIBNAME}>)
|
||||||
set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME})
|
set_target_properties(${LIBNAME}_static PROPERTIES
|
||||||
|
OUTPUT_NAME ${LIBNAME}
|
||||||
set(_libdir "${CMAKE_BINARY_DIR}/lib")
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
|
||||||
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()
|
endfunction()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user