summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-04-02 19:33:33 +0200
committerSlávek Banko <slavek.banko@axis.cz>2020-04-04 15:22:17 +0200
commit66dda475f9f54eb9b87466676dca3ef4dc84daa6 (patch)
tree4ab4a852b9d97c3a225eb4f671e2918f35f017d1
parent61682145da91b40d33ada36a15fe44fc83c17958 (diff)
downloadcmake-66dda475f9f54eb9b87466676dca3ef4dc84daa6.tar.gz
cmake-66dda475f9f54eb9b87466676dca3ef4dc84daa6.zip
Store ELF metadata as a separate target instead of the POST_BUILD command.
This allows naturally storing ELF metadata also in tdelibs. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit 48b1e42b64d8c5c47461db1bf0ca3db9ce3fe726)
-rw-r--r--modules/TDEMacros.cmake33
1 files changed, 23 insertions, 10 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 14e24b7..a6f52df 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -956,19 +956,29 @@ macro( tde_add_library _arg_target )
separate_arguments( ELF_EMBEDDING_METADATA )
if( TDELFEDITOR_EXECUTABLE AND _soname )
if( _version )
- add_custom_command(
- TARGET ${_target}
- POST_BUILD
- COMMAND ${TDELFEDITOR_EXECUTABLE} -m ${CMAKE_CURRENT_BINARY_DIR}/${_soname}.${_version} ${ELF_EMBEDDING_METADATA} || true
- COMMAND ${TDELFEDITOR_EXECUTABLE} -e ${CMAKE_CURRENT_BINARY_DIR}/${_soname}.${_version} || true
+ get_filename_component( _target_lib ${CMAKE_CURRENT_BINARY_DIR}/${_soname}.${_version} ABSOLUTE )
+ else( )
+ get_filename_component( _target_lib ${CMAKE_CURRENT_BINARY_DIR}/${_soname} ABSOLUTE )
+ endif( )
+ file( RELATIVE_PATH _target_path "${CMAKE_BINARY_DIR}" "${_target_lib}" )
+
+ if( NOT _exclude_from_all )
+ add_custom_target(
+ ${_target}+metadata ALL
+ COMMAND ${TDELFEDITOR_EXECUTABLE} -m ${_target_lib} ${ELF_EMBEDDING_METADATA} || true
+ COMMAND ${TDELFEDITOR_EXECUTABLE} -e ${_target_lib} || true
+ COMMENT "Storing SCM metadata in ${_target_path}"
+ DEPENDS ${_target} ${TDELFEDITOR_EXECUTABLE}
)
else( )
add_custom_command(
TARGET ${_target}
POST_BUILD
- COMMAND ${TDELFEDITOR_EXECUTABLE} -m ${CMAKE_CURRENT_BINARY_DIR}/${_soname} ${ELF_EMBEDDING_METADATA} || true
- COMMAND ${TDELFEDITOR_EXECUTABLE} -e ${CMAKE_CURRENT_BINARY_DIR}/${_soname} || true
+ COMMAND ${TDELFEDITOR_EXECUTABLE} -m ${_target_lib} ${ELF_EMBEDDING_METADATA} || true
+ COMMAND ${TDELFEDITOR_EXECUTABLE} -e ${_target_lib} || true
+ COMMENT "Storing SCM metadata in ${_target_path}"
)
+ add_dependencies( ${_target} ${TDELFEDITOR_EXECUTABLE} )
endif( )
endif( TDELFEDITOR_EXECUTABLE AND _soname )
@@ -1177,12 +1187,15 @@ macro( tde_add_executable _arg_target )
set( ELF_EMBEDDING_METADATA "\"${_target}\" \"${_description}\" \"${_license}\" \"${_copyright}\" \"${_authors}\" \"${_product}\" \"${_organization}\" \"${_version}\" \"${_datetime}\" \"${_target}\" \"${TDE_SCM_MODULE_NAME}\" \"${TDE_SCM_MODULE_REVISION}\" \"${_notes}\"" )
separate_arguments( ELF_EMBEDDING_METADATA )
if( TDELFEDITOR_EXECUTABLE )
- add_custom_command(
- TARGET ${_target}
- POST_BUILD
+ get_filename_component( _target_path ${CMAKE_CURRENT_BINARY_DIR}/${_target} ABSOLUTE )
+ file( RELATIVE_PATH _target_path "${CMAKE_BINARY_DIR}" "${_target_path}" )
+ add_custom_target(
+ ${_target}+metadata ALL
COMMAND ${TDELFEDITOR_EXECUTABLE} -m ${CMAKE_CURRENT_BINARY_DIR}/${_target} ${ELF_EMBEDDING_METADATA} || true
COMMAND ${TDELFEDITOR_EXECUTABLE} -e ${CMAKE_CURRENT_BINARY_DIR}/${_target} || true
COMMAND ${TDELFEDITOR_EXECUTABLE} -t ${CMAKE_CURRENT_BINARY_DIR}/${_target} ${_target} || true
+ COMMENT "Storing SCM metadata in ${_target_path}"
+ DEPENDS ${_target} ${TDELFEDITOR_EXECUTABLE}
)
endif( TDELFEDITOR_EXECUTABLE )