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>
pull/1/head
Slávek Banko 8 years ago
parent 2f44704668
commit edad8a20b9

@ -259,8 +259,14 @@ endmacro( )
macro( tde_install_la_file _target _destination ) macro( tde_install_la_file _target _destination )
get_target_property( _target_location ${_target} LOCATION ) get_target_property( _target_location ${_target} LOCATION )
get_target_property( _target_release ${_target} RELEASE )
get_filename_component( _soname ${_target_location} NAME ) 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 ) set( _laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la )
file( WRITE ${_laname} file( WRITE ${_laname}
@ -268,7 +274,7 @@ macro( tde_install_la_file _target _destination )
# The name that we can dlopen(3). # The name that we can dlopen(3).
dlname='${_soname}' dlname='${_soname}'
# Names of this library # Names of this library
library_names='${_soname} ${_soname} ${_soname}' library_names='${_soname} ${_soname} ${_soname_base}'
# The name of the static archive # The name of the static archive
old_library='' old_library=''
# Libraries that this one depends upon. # Libraries that this one depends upon.
@ -448,16 +454,19 @@ endmacro( __tde_internal_process_sources )
macro( tde_install_libtool_file _target _destination ) macro( tde_install_libtool_file _target _destination )
get_target_property( _target_location ${_target} LOCATION ) get_target_property( _target_location ${_target} LOCATION )
get_target_property( _target_release ${_target} RELEASE )
# 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 .so name # get .so name
get_filename_component( _soname ${_target_location} 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 version of target
get_target_property( _target_version ${_target} VERSION ) get_target_property( _target_version ${_target} VERSION )
@ -467,7 +476,7 @@ macro( tde_install_libtool_file _target _destination )
if( _target_version ) if( _target_version )
set( _library_name_1 "${_soname}.${_target_version}" ) set( _library_name_1 "${_soname}.${_target_version}" )
set( _library_name_2 "${_soname}.${_target_soversion}" ) 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}" ) string( REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" _dummy "${_target_version}" )
set( _version_current "${CMAKE_MATCH_1}" ) set( _version_current "${CMAKE_MATCH_1}" )
@ -478,7 +487,7 @@ macro( tde_install_libtool_file _target _destination )
else( _target_version ) else( _target_version )
set( _library_name_1 "${_soname}" ) set( _library_name_1 "${_soname}" )
set( _library_name_2 "${_soname}" ) set( _library_name_2 "${_soname}" )
set( _library_name_3 "${_soname}" ) set( _library_name_3 "${_soname_base}" )
set( _version_current "0" ) set( _version_current "0" )
set( _version_age "0" ) set( _version_age "0" )
set( _version_revision "0" ) set( _version_revision "0" )
@ -545,6 +554,7 @@ macro( tde_add_library _arg_target )
unset( _no_libtool_file ) unset( _no_libtool_file )
unset( _no_export ) unset( _no_export )
unset( _version ) unset( _version )
unset( _release )
unset( _sources ) unset( _sources )
unset( _destination ) unset( _destination )
unset( _embed ) unset( _embed )
@ -619,6 +629,12 @@ macro( tde_add_library _arg_target )
set( _storage "_version" ) set( _storage "_version" )
endif( "+${_arg}" STREQUAL "+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" # found directive "SOURCES"
if( "+${_arg}" STREQUAL "+SOURCES" ) if( "+${_arg}" STREQUAL "+SOURCES" )
set( _skip_store 1 ) set( _skip_store 1 )
@ -747,7 +763,13 @@ macro( tde_add_library _arg_target )
endif( ${_type} STREQUAL "MODULE" ) endif( ${_type} STREQUAL "MODULE" )
# set real name of target # 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} ) set_target_properties( ${_target} PROPERTIES OUTPUT_NAME ${_arg_target} )
endif( _release )
# set -fPIC flag for static libraries # set -fPIC flag for static libraries
if( _static_pic ) if( _static_pic )
@ -833,6 +855,20 @@ macro( tde_add_library _arg_target )
# install target # install target
install( TARGETS ${_target} DESTINATION ${_destination} ) 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 # install .la files for dynamic libraries
if( NOT "STATIC" STREQUAL ${_type} AND NOT _no_libtool_file ) if( NOT "STATIC" STREQUAL ${_type} AND NOT _no_libtool_file )
tde_install_libtool_file( ${_target} ${_destination} ) tde_install_libtool_file( ${_target} ${_destination} )

Loading…
Cancel
Save