summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-02-18 01:41:58 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-02-18 02:36:48 +0100
commit0a407527790db5dbf573ffba5dbac45048489c0a (patch)
tree0cecd9b45383d505117c4ee546ffc6fb83632119
parentf8254e1561c2a5a884a6f812ee5a0fdcf22c7884 (diff)
downloadcmake-0a407527790db5dbf573ffba5dbac45048489c0a.zip
cmake-0a407527790db5dbf573ffba5dbac45048489c0a.tar.gz
Add a function that determines the filename of the library
for the target. This replaces get_target_property( LOCATION ) that is deprecated due to CMP0026. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--modules/TDEMacros.cmake76
1 files changed, 44 insertions, 32 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 47a0dbe..af26e7c 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -110,18 +110,6 @@ endif( )
################################################
#####
-##### CMP0026 states we should not read the LOCATION property of a target,
-##### and should be using generators instead. We can't do that here however
-##### because we need the value of the property at configure time.
-
-if( POLICY CMP0026 )
- cmake_policy( PUSH )
- cmake_policy( SET CMP0026 OLD )
-endif( POLICY CMP0026 )
-
-
-################################################
-#####
##### tde_install_icons( <icons...> THEME <svgicons> DESTINATION <destdir> )
##### default theme: hicolor
##### default destination: ${SHARE_INSTALL_DIR}/icons
@@ -254,13 +242,51 @@ endmacro( )
#################################################
#####
+##### tde_get_library_filename( <var> <target> )
+
+function( tde_get_library_filename _filename _target )
+ get_target_property( _type ${_target} TYPE )
+ if( "${_type}" MATCHES "_LIBRARY" )
+ get_target_property( _output_prefix ${_target} PREFIX )
+ if( "${_output_prefix}" STREQUAL "_output_prefix-NOTFOUND" )
+ if( "${_type}" MATCHES "STATIC_" )
+ set( _output_prefix "${CMAKE_STATIC_LIBRARY_PREFIX}" )
+ elseif( "${_type}" MATCHES "SHARED_" )
+ set( _output_prefix "${CMAKE_SHARED_LIBRARY_PREFIX}" )
+ elseif( "${_type}" MATCHES "MODULE_" )
+ set( _output_prefix "${CMAKE_SHARED_MODULE_PREFIX}" )
+ else( )
+ set( _output_prefix "" )
+ endif( )
+ endif( )
+ get_target_property( _output_suffix ${_target} SUFFIX )
+ if( "${_output_suffix}" STREQUAL "_output_suffix-NOTFOUND" )
+ if( "${_type}" MATCHES "STATIC_" )
+ set( _output_suffix "${CMAKE_STATIC_LIBRARY_SUFFIX}" )
+ elseif( "${_type}" MATCHES "SHARED_" )
+ set( _output_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}" )
+ elseif( "${_type}" MATCHES "MODULE_" )
+ set( _output_suffix "${CMAKE_SHARED_MODULE_SUFFIX}" )
+ else( )
+ set( _output_suffix "" )
+ endif( )
+ endif( )
+ get_target_property( _output ${_target} OUTPUT_NAME )
+ set( ${_filename} "${_output_prefix}${_output}${_output_suffix}" PARENT_SCOPE )
+ else( )
+ set( ${_filename} "" PARENT_SCOPE )
+ endif( )
+endfunction( )
+
+
+#################################################
+#####
##### tde_install_la_file( <target> <destination> )
macro( tde_install_la_file _target _destination )
- get_target_property( _target_location ${_target} LOCATION )
+ tde_get_library_filename( _soname ${_target} )
get_target_property( _target_release ${_target} RELEASE )
- get_filename_component( _soname ${_target_location} NAME )
if( _target_release )
string( REPLACE "-${_target_release}" "" _soname_base "${_soname}" )
else( )
@@ -453,11 +479,9 @@ endmacro( __tde_internal_process_sources )
macro( tde_install_libtool_file _target _destination )
- get_target_property( _target_location ${_target} LOCATION )
- get_target_property( _target_release ${_target} RELEASE )
-
# get .so name
- get_filename_component( _soname ${_target_location} NAME )
+ tde_get_library_filename( _soname ${_target} )
+ get_target_property( _target_release ${_target} RELEASE )
if( _target_release )
string( REPLACE "-${_target_release}" "" _soname_base "${_soname}" )
else( )
@@ -840,8 +864,7 @@ macro( tde_add_library _arg_target )
if( "SHARED" STREQUAL ${_type} AND NOT _no_export )
# get target properties: output name, version, soversion
- get_target_property( _output ${_target} LOCATION )
- get_filename_component( _output ${_output} NAME )
+ tde_get_library_filename( _output ${_target} )
get_target_property( _version ${_target} VERSION )
get_target_property( _soversion ${_target} SOVERSION )
@@ -861,8 +884,7 @@ macro( tde_add_library _arg_target )
# install base soname
if( _release AND NOT "STATIC" STREQUAL ${_type} )
- get_target_property( _output ${_target} LOCATION )
- get_filename_component( _soname ${_output} NAME )
+ tde_get_library_filename( _output ${_target} )
string( REPLACE "-${_release}" "" _soname_base "${_soname}" )
if( _version )
get_target_property( _soversion ${_target} SOVERSION )
@@ -2146,13 +2168,3 @@ macro( tde_setup_polkit )
endif( )
endmacro( )
-
-
-################################################
-#####
-##### Restore CMP0026 policy
-
-if( POLICY CMP0026 )
- cmake_policy( POP )
-endif( POLICY CMP0026 )
-