Add support for libraries with release number in the name of the library

See https://www.gnu.org/software/libtool/manual/html_node/Release-numbers.html

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit edad8a20b9)
v3.5.13-sru
Slávek Banko 8 years ago
parent 40c1d8a29f
commit e1bba2385e

@ -259,8 +259,14 @@ endmacro( )
macro( tde_install_la_file _target _destination )
get_target_property( _target_location ${_target} LOCATION )
get_target_property( _target_release ${_target} RELEASE )
get_filename_component( _soname ${_target_location} NAME )
string( REGEX REPLACE "\\.so(\\.[0-9]+)*$" "" _laname "${_soname}" )
if( _target_release )
string( REPLACE "-${_target_release}" "" _soname_base "${_soname}" )
else( )
set( _soname_base ${_soname} )
endif( )
string( REGEX REPLACE "\\.so(\\.[0-9]+)*$" "" _laname "${_soname_base}" )
set( _laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la )
file( WRITE ${_laname}
@ -268,7 +274,7 @@ macro( tde_install_la_file _target _destination )
# The name that we can dlopen(3).
dlname='${_soname}'
# Names of this library
library_names='${_soname} ${_soname} ${_soname}'
library_names='${_soname} ${_soname} ${_soname_base}'
# The name of the static archive
old_library=''
# Libraries that this one depends upon.
@ -448,16 +454,19 @@ endmacro( __tde_internal_process_sources )
macro( tde_install_libtool_file _target _destination )
get_target_property( _target_location ${_target} LOCATION )
# get name of target
get_filename_component( _name ${_target_location} NAME )
string( REGEX REPLACE "\\.so(\\.[0-9]+)*$" "" _name "${_name}" )
# get .la name
set( _laname ${_name}.la )
get_target_property( _target_release ${_target} RELEASE )
# get .so name
get_filename_component( _soname ${_target_location} NAME )
if( _target_release )
string( REPLACE "-${_target_release}" "" _soname_base "${_soname}" )
else( )
set( _soname_base ${_soname} )
endif( )
# get .la name
string( REGEX REPLACE "\\.so(\\.[0-9]+)*$" "" _laname "${_soname_base}" )
set( _laname ${_laname}.la )
# get version of target
get_target_property( _target_version ${_target} VERSION )
@ -467,7 +476,7 @@ macro( tde_install_libtool_file _target _destination )
if( _target_version )
set( _library_name_1 "${_soname}.${_target_version}" )
set( _library_name_2 "${_soname}.${_target_soversion}" )
set( _library_name_3 "${_soname}" )
set( _library_name_3 "${_soname_base}" )
string( REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" _dummy "${_target_version}" )
set( _version_current "${CMAKE_MATCH_1}" )
@ -478,7 +487,7 @@ macro( tde_install_libtool_file _target _destination )
else( _target_version )
set( _library_name_1 "${_soname}" )
set( _library_name_2 "${_soname}" )
set( _library_name_3 "${_soname}" )
set( _library_name_3 "${_soname_base}" )
set( _version_current "0" )
set( _version_age "0" )
set( _version_revision "0" )
@ -545,6 +554,7 @@ macro( tde_add_library _arg_target )
unset( _no_libtool_file )
unset( _no_export )
unset( _version )
unset( _release )
unset( _sources )
unset( _destination )
unset( _embed )
@ -604,6 +614,12 @@ macro( tde_add_library _arg_target )
set( _storage "_version" )
endif( "+${_arg}" STREQUAL "+VERSION" )
# found directive "RELEASE"
if( "+${_arg}" STREQUAL "+RELEASE" )
set( _skip_store 1 )
set( _storage "_release" )
endif( "+${_arg}" STREQUAL "+RELEASE" )
# found directive "SOURCES"
if( "+${_arg}" STREQUAL "+SOURCES" )
set( _skip_store 1 )
@ -694,7 +710,13 @@ macro( tde_add_library _arg_target )
endif( ${_type} STREQUAL "MODULE" )
# set real name of target
if( _release )
# add release number to output name
set_target_properties( ${_target} PROPERTIES RELEASE ${_release} )
set_target_properties( ${_target} PROPERTIES OUTPUT_NAME "${_arg_target}-${_release}" )
else( _release )
set_target_properties( ${_target} PROPERTIES OUTPUT_NAME ${_arg_target} )
endif( _release )
# set -fPIC flag for static libraries
if( _static_pic )
@ -780,6 +802,20 @@ macro( tde_add_library _arg_target )
# install target
install( TARGETS ${_target} DESTINATION ${_destination} )
# install base soname
if( _release AND NOT "STATIC" STREQUAL ${_type} )
get_target_property( _output ${_target} LOCATION )
get_filename_component( _soname ${_output} NAME )
string( REPLACE "-${_release}" "" _soname_base "${_soname}" )
if( _version )
get_target_property( _soversion ${_target} SOVERSION )
set( _soname "${_soname}.${_soversion}" )
endif( )
add_custom_command( TARGET ${_target} POST_BUILD
COMMAND ln -s ${_soname} "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}" )
install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}" DESTINATION ${_destination} )
endif( )
# install .la files for dynamic libraries
if( NOT "STATIC" STREQUAL ${_type} AND NOT _no_libtool_file )
tde_install_libtool_file( ${_target} ${_destination} )

Loading…
Cancel
Save