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...
macro(my_target_link_libraries target )
if(CMAKE_COMPILER_IS_GNUCC)
foreach( target_lib ${ARGN} )
if( TARGET ${target_lib} )
get_property( lib_path TARGET ${target_lib} PROPERTY LOCATION)
if( ${lib_path} MATCHES "(.*)/([^/]*)$" )
get_target_property(existing_link_flags ${target}
LINK_FLAGS)
if(existing_link_flags)
set(new_link_flags "${existing_link_flags} -L
${CMAKE_MATCH_1} -l ${target_lib}")
else()
set(new_link_flags "-L ${CMAKE_MATCH_1} -l
${target_lib}")
endif()
set_target_properties( ${target} PROPERTIES LINK_FLAGS
${new_link_flags})
endif( ${lib_path} MATCHES "(.*)/([^/]*)$" )
else()
target_link_libraries( ${target} ${target_lib} )
endif( TARGET ${target_lib} )
endforeach( target_lib ${ARGN} )
else()
target_link_libraries( ${target} ${ARGN} )
endif()
endmacro()
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake