Is there any way to remove a library from the LINK_LIBRARIES
added by target_link_libraries
?
target_link_libraries(Project library1 library2)
get_target_property(cur_cflags Project LINK_LIBRARIES)
message(STATUS ${cur_cflags})
# should print library1 and library2
# here I do something to remove library1
get_target_property(cur_cflags Project LINK_LIBRARIES)
message(STATUS ${cur_cflags})
#should print library2 only
Thanks
Check this
target_link_libraries(Project PRIVATE library1 library2)
get_target_property(TARGET_LIBRARIES Project LINK_LIBRARIES)
message("Libraries at start")
message(${TARGET_LIBRARIES})
LIST(REMOVE_ITEM TARGET_LIBRARIES library1 )
message("Modified libraries list")
message(${TARGET_LIBRARIES})
set_property(TARGET Project PROPERTY LINK_LIBRARIES ${TARGET_LIBRARIES} )
get_target_property(TARGET_LIBRARIES2 Project LINK_LIBRARIES)
message("Libraries after change")
message(${TARGET_LIBRARIES2})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With