<div dir="ltr"><div style>alternate target_link_libraries. Usage is the same. Test if each library to link is a target, get that targets path, and break it into parts and add it to LINK_FLAGS else add with target_link_libraries...</div>
<div><br></div><div>macro(my_target_link_libraries target )</div><div> if(CMAKE_COMPILER_IS_GNUCC)</div><div> foreach( target_lib ${ARGN} )</div><div> if( TARGET ${target_lib} )</div><div> get_property( lib_path TARGET ${target_lib} PROPERTY LOCATION)</div>
<div> if( ${lib_path} MATCHES "(.*)/([^/]*)$" )</div><div> get_target_property(existing_link_flags ${target} LINK_FLAGS)</div><div> if(existing_link_flags)</div><div> set(new_link_flags "${existing_link_flags} -L ${CMAKE_MATCH_1} -l ${target_lib}")</div>
<div> else()</div><div> set(new_link_flags "-L ${CMAKE_MATCH_1} -l ${target_lib}")</div><div> endif()</div><div> set_target_properties( ${target} PROPERTIES LINK_FLAGS ${new_link_flags})</div>
<div> endif( ${lib_path} MATCHES "(.*)/([^/]*)$" )</div><div> else()</div><div> target_link_libraries( ${target} ${target_lib} )</div><div> endif( TARGET ${target_lib} )</div>
<div> endforeach( target_lib ${ARGN} )</div><div> else()</div><div> <span class="" style="white-space:pre">        </span>target_link_libraries( ${target} ${ARGN} )</div><div> endif()</div><div>endmacro()</div><div>
<br></div></div>