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 )