diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2020-05-24 02:07:19 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2020-05-24 18:47:30 +0200 |
commit | 81c6a60fac93e6610b2ea8599b6d2636df4fcd98 (patch) | |
tree | bb581b9715658da7bed23d7acef7e913eb2705d5 | |
parent | 74122e5d1f587daa65b600fd30408517d4641bf7 (diff) | |
download | tde-cmake-81c6a60fac93e6610b2ea8599b6d2636df4fcd98.tar.gz tde-cmake-81c6a60fac93e6610b2ea8599b6d2636df4fcd98.zip |
Write metadata to libraries and executables using the post-build command,
except when building tdelibs, where a separate target will be used and
writing metadata will be the last step.
This also resolve TDE/tdelibs#80.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 374fcabb184ddc3d455d8037a9cbdc20fd60744f)
-rw-r--r-- | modules/TDEMacros.cmake | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 1fdda9c..2a3701b 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -1113,7 +1113,7 @@ macro( tde_add_library _arg_target ) endif( ) file( RELATIVE_PATH _target_path "${CMAKE_BINARY_DIR}" "${_target_lib}" ) - if( NOT _exclude_from_all ) + if( TARGET ${TDELFEDITOR_EXECUTABLE} AND NOT _exclude_from_all ) # create target for all metadata writes if( NOT TARGET tdelfeditor-write ) add_custom_target( tdelfeditor-write @@ -1138,7 +1138,9 @@ macro( tde_add_library _arg_target ) COMMAND ${TDELFEDITOR_EXECUTABLE} -e ${_target_lib} || true COMMENT "Storing SCM metadata in ${_target_path}" ) - add_dependencies( ${_target} ${TDELFEDITOR_EXECUTABLE} ) + if( TARGET ${TDELFEDITOR_EXECUTABLE} ) + add_dependencies( ${_target} ${TDELFEDITOR_EXECUTABLE} ) + endif() endif( ) endif( TDELFEDITOR_EXECUTABLE AND _soname ) @@ -1347,25 +1349,35 @@ 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 ) - # create target for all metadata writes - if( NOT TARGET tdelfeditor-write ) - add_custom_target( tdelfeditor-write - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - DEPENDS ${TDELFEDITOR_EXECUTABLE} - COMMENT "Write metadata to binaries..." - ) - endif( ) 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 tdelfeditor-write - ) - add_dependencies( tdelfeditor-write ${_target} ) + if( TARGET ${TDELFEDITOR_EXECUTABLE} ) + # create target for all metadata writes + if( NOT TARGET tdelfeditor-write ) + add_custom_target( tdelfeditor-write + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + DEPENDS ${TDELFEDITOR_EXECUTABLE} + COMMENT "Write metadata to binaries..." + ) + endif( ) + 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 + COMMENT "Storing SCM metadata in ${_target_path}" + DEPENDS tdelfeditor-write + ) + add_dependencies( tdelfeditor-write ${_target} ) + else() + add_custom_command( + TARGET ${_target} + POST_BUILD + 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}" + ) + endif() endif( TDELFEDITOR_EXECUTABLE ) endmacro( tde_add_executable ) |