summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-05-24 02:07:19 +0200
committerSlávek Banko <slavek.banko@axis.cz>2020-05-24 09:51:24 +0200
commit374fcabb184ddc3d455d8037a9cbdc20fd60744f (patch)
tree0c4b4371d0bd0b6a2d860d1c676996520b1e7274
parent34e3154c44c59da784cfad7dcb63497b374cbd7d (diff)
downloadcmake-374fcabb184ddc3d455d8037a9cbdc20fd60744f.tar.gz
cmake-374fcabb184ddc3d455d8037a9cbdc20fd60744f.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>
-rw-r--r--modules/TDEMacros.cmake50
1 files changed, 31 insertions, 19 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 90fbeaa..febfc0c 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 )